Commit Graph

74 Commits

Author SHA1 Message Date
f23397c0c0 pkg/*: clean up a few issues
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: a23c456e5a136d65d02d66af398af1e3ce3a4081
Component: engine
2017-03-30 16:50:46 +03:00
4defdd0e1e Fix deadlock on v1 plugin with activate error
When a plugin has an activation error, it was not being checked in the
`waitActive` loop. This means it will just wait forever for a manifest
to be populated even though it may never come.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: f2d384fca6fa08da13fdc01c7991e8e35b081198
Component: engine
2017-01-24 11:08:13 -05:00
964854de91 Fix pluginv1 Windows volumes
c54b717 caused a regression for pluginv1 on Windows, where extraneous
backslashes were added to BasePath of the plugin. For pluginv1 on windows,
BasePath() should return an empty string, since the plugin is fully aware
of the mount path. Also, unlike Linux where all paths are relative to "/",
Windows paths are dependent on system drives and mapped drives.

Fixes #30148

Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>
Upstream-commit: 0ef21eb0e30d2ea036730a7c5502f888c6b763d1
Component: engine
2017-01-13 17:01:48 -08:00
bd5280d393 Fix race accessing plugin storage map
`plugins.GetAll()` was not locking the plugin map when checking if a
plugin exists, this can cause a race and potentially a panic if another
goroutine is trying to load a plugin into the map at the same time.

Also fixes a race during activation where a plugin inserts itself into
the plugin map but does not check if something else is already there.
This is already checked before trying to activate the plugin, however
the map lock is not held for this entire period, so other plugins may be
loaded during this time.
To fix, before inserting the plugin into the map, check if one with the
same name already exists and use that instead.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 21fcbb39b73310e69d6403a1cfa8b26799cc1355
Component: engine
2017-01-05 22:40:45 -05:00
25dd6a8c20 Merge pull request #29733 from cpuguy83/fix_v1plugin_deadlock
Fix race/deadlock in v1 plugin handlers
Upstream-commit: 48ed4f0639d2f290603a04ec146beb3f9569280f
Component: engine
2017-01-03 17:02:15 -08:00
6b571eeb83 Fix race/deadlock in v1 plugin handlers
When a plugin is activated, and then `plugins.Handle` is called to
register a new handler for a given plugin type, a deadlock occurs when
for anything which calls `waitActive`, including `Get`, and `GetAll`.

This happens because `Handle()` is setting `activated` to `false` to
ensure that plugin handlers are run on next activation.
Maybe these handlers should be called immediately for any plugins which
are already registered... but to preserve the existing behavior while
fixing the deadlock, track if handlers have been run on plugins and
reset when a new handler is registered.

The simplest way to reproduce the deadlock with Docker is to add a `-v
/foo` to the test container created for the external graphdriver tests.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 2938dce794be7559ba73b4e9630015020a7fa937
Component: engine
2016-12-27 12:27:41 -05:00
44fa4f8ae7 duplicated the
Signed-off-by: Jie Luo <luo612@zju.edu.cn>

typo

Signed-off-by: Jie Luo <luo612@zju.edu.cn>

fix some typos

Signed-off-by: Jie Luo <luo612@zju.edu.cn>
Upstream-commit: ea2dd4b5d0b41552d047814d9e39ddaa3662ab41
Component: engine
2016-12-21 20:16:19 +08:00
656f60dc73 plugins: container-rootfs-relative paths
Legacy plugins expect host-relative paths (such as for Volume.Mount).
However, a containerized plugin cannot respond with a host-relative
path. Therefore, this commit modifies new volume plugins' paths in Mount
and List to prepend the container's rootfs path.

This introduces a new PropagatedMount field in the Plugin Config.
When it is set for volume plugins, RootfsPropagation is set to rshared
and the path specified by PropagatedMount is bind-mounted with rshared
prior to launching the container. This is so that the daemon code can
access the paths returned by the plugin from the host mount namespace.

Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: c54b717caf1a55e525ce180bfcb42addd59c6633
Component: engine
2016-12-09 10:16:24 -08:00
c21adc5da9 Add HTTP client timeout.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 83ca993c154d56e03d6f95a3f8351c48b3ed3e29
Component: engine
2016-11-21 13:11:40 -08:00
f449f9bc63 prevent data race in pkg/plugins
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: f7af80860cf99ce808834260ac190a2a88bc24e2
Component: engine
2016-10-21 13:28:13 -07:00
1050d22554 Allow plugins to have multiple handlers
Currently the plugins pkg allows a single handler. This assumption
breaks down if there are mutiple listeners to a plugin of a certain
Manifest such as NetworkDriver or IpamDriver when swarm-mode is enabled.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Upstream-commit: 5e9c78aeaf1d88000921190b88a1d91d6261208c
Component: engine
2016-10-17 09:00:17 -07:00
f07146ebf8 Make graphdrivers work with pluginv2.
As part of making graphdrivers support pluginv2, a PluginGetter
interface was necessary for cleaner separation and avoiding import
cycles.

This commit creates a PluginGetter interface and makes pluginStore
implement it. Then the pluginStore object is created in the daemon
(rather than by the plugin manager) and passed to plugin init as
well as to the different subsystems (eg. graphdrivers, volumedrivers).
A side effect of this change was that some code was moved out of
experimental. This is good, since plugin support will be stable soon.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: fefea805e930a67fb6327f8e59415932861358cb
Component: engine
2016-09-20 08:49:48 -07:00
4cd6f89f27 Revert "Add default timeout to pkg/plugins/client"
This reverts commit 0699b00d26a60f4a8447572b34c4aad1ce73d2e1.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 5c35bfed3f4823e205c5d5b171f23972ff8b3de0
Component: engine
2016-09-20 10:01:03 +02:00
1dc2c82ca8 Fix flaky unit test
Fix flaky test `TestHTTPTimeout` caused by precision problem.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: bc5768733db79874d8918e8499df01d68cae2d6e
Component: engine
2016-09-17 19:40:58 +08:00
6bbb3e807c fix racy test in pkg/plugins
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: 4bc908ec8910468711960a4bcd4f3ec8dce909fb
Component: engine
2016-09-16 01:43:35 +00:00
9a4ddab230 Add default timeout to pkg/plugins/client
Signed-off-by: Chun Chen <ramichen@tencent.com>
Upstream-commit: 0699b00d26a60f4a8447572b34c4aad1ce73d2e1
Component: engine
2016-09-12 10:39:32 +08:00
833a33ebb8 Fix govet for go1.7
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 7a8c7b47cffa8485b03db715f78c087b01ae5dfa
Component: engine
2016-09-02 19:07:54 -07:00
7c9671c819 fix spec file support for Windows plugin discovery (#25903)
Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
Upstream-commit: 52c0daad82b424afc661c23c1d80784d014e1a58
Component: engine
2016-08-26 22:11:58 +02:00
cb628977aa Add spec file support for Windows plugin discovery.
Plugin discovery on Windows is not possible using named pipes. However,
it is possible using spec file (tcp based). This adds Windows specific
paths for discovery.

Fixes #23605

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 36cf93fb0c45ce62b3cb1e82e1ecae1486017c9b
Component: engine
2016-08-22 09:14:57 -07:00
ac18bf29a1 Fix pkg/plugins TLSConfig panic
Fix #25046

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: b1e71bdd1d624e297509a62b072082524dc841fc
Component: engine
2016-07-26 08:53:54 +00:00
0228458e3c Add only legacy plugins to the legacy lookup map.
Legacy plugin model maintained a map of plugins. This is
not used by the new model. Using this map in the new model
causes incorrect lookup of plugins. This change uses adds
a plugin to the map only if its legacy.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 8fd779dc28a11d8727d76e9553379b0c854f7c4c
Component: engine
2016-07-18 15:43:44 -07:00
848e510213 plugins: experimental support for new plugin management
This patch introduces a new experimental engine-level plugin management
with a new API and command line. Plugins can be distributed via a Docker
registry, and their lifecycle is managed by the engine.
This makes plugins a first-class construct.

For more background, have a look at issue #20363.

Documentation is in a separate commit. If you want to understand how the
new plugin system works, you can start by reading the documentation.

Note: backwards compatibility with existing plugins is maintained,
albeit they won't benefit from the advantages of the new system.

Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: f37117045c5398fd3dca8016ea8ca0cb47e7312b
Component: engine
2016-06-14 14:20:27 -07:00
87c4c2885f authz: cleanups
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: d1b7e8373bde77819a25fce94bdfa9725608215e
Component: engine
2016-06-12 17:23:19 +02:00
da4d783e80 Add support for volume scopes
This is similar to network scopes where a volume can either be `local`
or `global`. A `global` volume is one that exists across the entire
cluster where as a `local` volume exists on a single engine.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 2f40b1b281a3be8f34d82a5170988ee46ea1f442
Component: engine
2016-06-05 15:37:15 -04:00
6e1304c58a Enhance pluginrpc-gen parser
Now handles `package.Type` and `*package.Type`
Fixes parsing issues with slice and map types.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 79ff6eaf21dfebad0f8131a1ede235249cd6638f
Component: engine
2016-06-05 15:37:15 -04:00
de046a0cf3 When calling volume driver Mount, send opaque ID
This generates an ID string for calls to Mount/Unmount, allowing drivers
to differentiate between two callers of `Mount` and `Unmount`.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 2b6bc294fc7f9e08a9091833b021b7d2a01ad2a6
Component: engine
2016-04-29 09:37:02 -04:00
ee5a4917fb Initialize activateWait for plugins activated by json spec
Signed-off-by: Madhu Venugopal <madhu@docker.com>
Upstream-commit: de806a672b0810e48facc74e198e6728c1fe2c6d
Component: engine
2016-04-20 05:59:19 -07:00
1946302b86 fix typo in comment
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: 76122f95e9173c1182b8dd44e1aa236a045d4e6a
Component: engine
2016-04-08 00:05:31 -07:00
3420db4b5e Fix panic in loading plugins
When a plugin is first found, it is loaded into the available plugins
even though it's not activated yet.
If activation fails it is taken out of the list.
While it is in the list, other callers may see it and try to check it's
manifest. If it is not fully activated yet, the manifest will be nil and
cause a panic.

This is especially problematic for drivers that are down and have not
been activated yet.

We could just not load the plugin into the available list until it's
fully active, however that will just cause multiple of the same plugin
to attemp to be loaded.

We could check if the manifest is nil and return early (instead of
panicing on a nil manifest), but this will cause a 2nd caller to receive
a response while the first caller is still waiting, which can be
awkward.

This change uses a condition variable to handle activation (instead of
sync.Once). If the plugin is not activated, callers will all wait until
it is activated and receive a broadcast from the condition variable
signaling that it's ok to proceed, in which case we'll check if their
was an error in activation and proceed accordingly.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: baac2f48674d42863f9fdca5ef3056b4c6ed707e
Component: engine
2016-03-23 15:34:15 -04:00
195d725261 *: fix response body leaks
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: f0d83c4cdb49adb53fdaf4216a4395c23d5cc8e9
Component: engine
2016-03-16 17:15:42 +01:00
4a285f2027 Call plugins with custom transports.
Small refactor to be able to use custom transports
to call remote plugins.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1a630234508bdb12d55425ceebdb0b6523a38578
Component: engine
2016-03-02 12:54:53 -05:00
569a4e8006 Merge pull request #20686 from clintonskitson/bugfix/plugin_desc_leak
Fix plugin file descriptor leaks
Upstream-commit: 29b2b0c22ba4a9c81002cd70e464ef0cfc577413
Component: engine
2016-02-29 10:44:36 -08:00
fac52dba98 Fixes plugin file descriptor leak on plugin discovery
Signed-off-by: Clinton Kitson <clintonskitson@gmail.com>
Upstream-commit: 799ae78b7efa9ffb8e142a0a211325cca59987be
Component: engine
2016-02-26 19:43:50 -08:00
1ca6d4e7c1 Close resp body on plugin call error
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 93ad9c31fce375b29606ea347df28c1205e7cb41
Component: engine
2016-02-24 20:09:51 -05:00
f62b97e499 Fix some typos in comments and strings
Most of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Upstream-commit: 2eee613326fb59fd168849618d14a9054a40f9f5
Component: engine
2016-02-22 20:27:15 +01:00
4f226110ac Add support for forwarding Docker client through SOCKS proxy
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 05002c2501ac549b3cf677ab04d0f571cc456360
Component: engine
2016-02-16 11:09:28 -08:00
697a990701 fix common misspell
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: 99a396902f0ea9d81ef87a683489b2435408f415
Component: engine
2016-02-11 15:49:36 -08:00
31b16ed933 Windows CI: test-unit on pkg\plugins
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 4b3001e85aff2c51a69eec205023e32384bebbdf
Component: engine
2016-02-10 19:28:30 -08:00
32fac24f32 Apply context changes to the client.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: fe53be4e1785ab4d8cadf246e5f2de419f337adc
Component: engine
2016-02-04 13:59:57 -05:00
f0e82098a7 Add back compat for volume drivers Get and Ls
Use a back-compat struct to handle listing volumes for volumes we know
about (because, presumably, they are being used by a container) for
volume drivers which don't yet support `List`.

Adds a fall-back for the volume driver `Get` call, which will use
`Create` when the driver returns a `404` for `Get`. The old behavior was
to always use `Create` to get a volume reference.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: f6c20d9b22ec9913f67b6c2ebdb5ef07c87b8cd7
Component: engine
2016-01-22 22:48:17 -05:00
7e789b4066 Bump plugin API version
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 54587d861d6664d6d32bc62a46c0c7ea0c7853e6
Component: engine
2016-01-21 11:41:32 -05:00
6262193ba3 Don't error out on plugin err with json
We don't want to error out when there is a json unmarshal error since
the `old way` will cause this to error.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 279dd092b6e9d5f6bb405440fa8d407349f5ad84
Component: engine
2016-01-06 11:34:14 -05:00
db1910a30c Move responsibility of ls/inspect to volume driver
Makes `docker volume ls` and `docker volume inspect` ask the volume
drivers rather than only using what is cached locally.

Previously in order to use a volume from an external driver, one would
either have to use `docker volume create` or have a container that is
already using that volume for it to be visible to the other volume
API's.

For keeping uniqueness of volume names in the daemon, names are bound to
a driver on a first come first serve basis. If two drivers have a volume
with the same name, the first one is chosen, and a warning is logged
about the second one.

Adds 2 new methods to the plugin API, `List` and `Get`.
If a plugin does not implement these endpoints, a user will not be able
to find the specified volumes as well requests go through the drivers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: d3eca4451d264aac564594fe46b8c097bd85a5cc
Component: engine
2016-01-05 16:28:38 -05:00
51b37769f0 Remove usage of pkg sockets and tlsconfig.
- Use the ones provided by docker/go-connections, they are a drop in replacement.
- Remove pkg/sockets from docker.
- Keep pkg/tlsconfig because libnetwork still needs it and there is a
  circular dependency issue.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 8e034802b7ad92a29f08785e553415adcd1348a3
Component: engine
2015-12-29 19:27:12 -05:00
547bf07eca pkg: authorization: do not register the same plugin
This patches avoids registering (and calling) the same plugin more than
once. Using an helper map which indexes by name guarantees this and keeps
the order.
The behavior of overriding the same name in a flag is consistent with,
for instance, the `docker run -v /test -v /test` flag which register
the volume just once.
Adds integration tests.

Without this patch:
```
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.080901676+01:00" level=debug msg="Calling
GET
/v1.22/info"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081213202+01:00" level=debug msg="AuthZ
request using plugin docker-novolume-plugin"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081268132+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081699788+01:00" level=debug msg="AuthZ
request using plugin docker-novolume-plugin"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081762507+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.082092480+01:00" level=debug msg="GET
/v1.22/info"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.628691038+01:00" level=debug msg="AuthZ
response using plugin docker-novolume-plugin"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.629880930+01:00" level=debug msg="AuthZ
response using plugin docker-novolume-plugin"
```

With this patch:
```
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.376523958+01:00" level=debug msg="Calling
GET
/v1.22/info"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.376715483+01:00" level=debug msg="AuthZ
request using plugin docker-novolume-plugin"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.376771230+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.377698897+01:00" level=debug msg="GET
/v1.22/info"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.951016441+01:00" level=debug msg="AuthZ
response using plugin docker-novolume-plugin"
```

Also removes a somehow duplicate debug statement (leaving only the
second one as it's a loop of plugin's manifest):
```
Dec 20 19:52:30 localhost.localdomain docker[25767]:
time="2015-12-20T19:52:30.544090518+01:00" level=debug
msg="docker-novolume-plugin's manifest: &{[authz]}"
Dec 20 19:52:30 localhost.localdomain docker[25767]:
time="2015-12-20T19:52:30.544170677+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
```

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: c28fc06e002e06deed3437da76bc213b7bd752ba
Component: engine
2015-12-23 21:08:40 +01:00
d63981ab4d authZ: more fixes
- fix naming and formatting
- provide more context when erroring auth
- do not capitalize errors
- fix wrong documentation
- remove ugly remoteError{}

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 5a64c8027ecd2bebe773c9abd2e73c2fd7d23de1
Component: engine
2015-12-18 16:29:01 +01:00
6862b2ec45 pkg: plugins: remove dead code
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 1d2b62ceae17238f842bb2a7febf1bead8a982d5
Component: engine
2015-12-17 11:05:50 +01:00
dcc0a93ee4 pkg: plugins: fix and better handle errors
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 4133dc22122c6a032276adb073d651bc6aca181b
Component: engine
2015-12-15 17:51:48 +01:00
54d257ee92 pkg/plugins/client.go: don't try to encode os decode if it's nil
When user call the `Call()` method, they don't always want to sent
some args or get the return value, so they use `nil` when call `Call()`
method and this will casue an error. It's better to not trying to
encode or decode if it's nil.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: a2d348968fe754df41d0a1b56c7ba29ebbaa6849
Component: engine
2015-12-05 02:55:50 -05:00
93c2a19d83 Add user namespace (mapping) support to the Docker engine
Adds support for the daemon to handle user namespace maps as a
per-daemon setting.

Support for handling uid/gid mapping is added to the builder,
archive/unarchive packages and functions, all graphdrivers (except
Windows), and the test suite is updated to handle user namespace daemon
rootgraph changes.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Upstream-commit: 442b45628ee12ebd8e8bd08497896d5fa8eec4bd
Component: engine
2015-10-09 17:47:37 -04:00