Commit Graph

50 Commits

Author SHA1 Message Date
30a11974ed Merge pull request #31930 from anusha-ragunathan/authz-disable
When authz plugin is disabled, remove from authz middleware chain.
Upstream-commit: bbce24997c7a31454edd1d3d979823582bcdd95d
Component: engine
2017-03-22 14:17:38 -07:00
2034662b7a When authz plugin is disabled, remove from authz middleware chain.
When the daemon is configured to run with an authorization-plugin and if
the plugin is disabled, the daemon continues to send API requests to the
plugin and expect it to respond. But the plugin has been disabled. As a
result, all API requests are blocked. Fix this behavior by removing the
disabled plugin from the authz middleware chain.

Tested using riyaz/authz-no-volume-plugin and observed that after
disabling the plugin, API request/response is functional.

Fixes #31836

Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>
Upstream-commit: 38de272bd4dfea945985b7031cd353ac5f6507c5
Component: engine
2017-03-22 12:07:39 -07:00
48ffb5882e Wait to unmount propagatedmount before marking plugin as disabled.
TestPluginTrustedInstall revealed a race in the plugin shutdown logic,
where the exit channel signal was sent even before the propagated mounts
were unmounted. If the same plugin was enabled, it would try to setup
propagated mounts *before* it was unmounted resulting in errors.

This change fixes the behavior by waiting until the unmount completes on
disable before marking the plugin as disabled.

Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>
Upstream-commit: 70b76266b586d193c333aa37dcda031f3d89f108
Component: engine
2017-03-16 15:25:41 -07:00
5c62127220 Merge pull request #29742 from miaoyq/rewrite-validate-privileges
Rewrite the function 'validatePrivileges' without checking order
Upstream-commit: 0ac25dfc751fa4304ab45afd5cd8705c2235d101
Component: engine
2017-02-17 10:24:11 +01:00
9bd3ca6b09 Rewrite the function 'validatePrivileges' without checking order
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: dafeeac4fd0ba811a4d88fe9ee335992680c8ad3
Component: engine
2017-02-04 08:47:40 +08:00
a14a8b183d Make propagated mount persist outside rootfs
This persists the "propagated mount" for plugins outside the main
rootfs. This enables `docker plugin upgrade` to not remove potentially
important data during upgrade rather than forcing plugin authors to hard
code a host path to persist data to.

Also migrates old plugins that have a propagated mount which is in the
rootfs on daemon startup.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: e8307b868de9f19bb97f5cafcd727df5c5f501be
Component: engine
2017-02-03 16:22:58 -05:00
83cd2e6903 plugin: use pkg/errors in more places
Also provide stack trace output in daemon logs.

Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 26d0bac8955903bc3a845358d159b2ec2f7c253f
Component: engine
2017-01-31 16:45:26 -08:00
027b11b8c3 Remove use of forked reference package for cli
Use resolving to repo info as the split point between the
legitimate reference package and forked reference package.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 0421f5173dbdcb4e4eade5267f274302bb6ab97c
Component: engine
2017-01-19 16:04:50 -08:00
775c5633ef *: use opencontainers/go-digest package
The `digest` data type, used throughout docker for image verification
and identity, has been broken out into `opencontainers/go-digest`. This
PR updates the dependencies and moves uses over to the new type.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: 7a855799175b6b984886ef1cfa337d6df1d4c668
Component: engine
2017-01-06 18:48:41 -08:00
75dc0839ff Fix validation of plugins without rootfs in config
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 6c7cb520094866cacbecb96695aed2d67d8a64a0
Component: engine
2016-12-27 15:36:12 -08:00
478844dff8 Implement content addressability for plugins
Move plugins to shared distribution stack with images.

Create immutable plugin config that matches schema2 requirements.

Ensure data being pushed is same as pulled/created.

Store distribution artifacts in a blobstore.

Run init layer setup for every plugin start.

Fix breakouts from unsafe file accesses.

Add support for `docker plugin install --alias`

Uses normalized references for default names to avoid collisions when using default hosts/tags.

Some refactoring of the plugin manager to support the change, like removing the singleton manager and adding manager config struct.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Upstream-commit: 3d86b0c79b16334ce5836c0315e4c310b84c2e17
Component: engine
2016-12-23 13:29:58 -08:00
8616ae37b9 Merge pull request #29423 from unclejack/api_cli_integ_return
return directly without ifs in remaining packages
Upstream-commit: 21210419447281863f239805ab19248733041a52
Component: engine
2016-12-17 21:30:47 +01:00
b70f98ab3e Make graphdriver plugin use plugin BasePath
Also enables `PropagatedMount` for graphdrivers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 500210475f6d841b2eacb42fb495e90108db2733
Component: engine
2016-12-15 16:22:13 -05:00
d363742779 return directly without ifs in remaining packages
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: 2c187a24e0003f2f0ab90b85876e668f2b6210d4
Component: engine
2016-12-14 23:28:27 +02: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
3889503c60 Make v2/Plugin accesses safe.
v2/Plugin struct had fields that were
- purely used by the manager.
- unsafely exposed without proper locking.
This change fixes this, by moving relevant fields to the manager as well
as making remaining fields as private and providing proper accessors for
them.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: b35490a8ba2ad70a585c1ba8109b6d87aece8daa
Component: engine
2016-12-06 13:23:41 -08:00
c06179cb55 Fix issue caused by duplicate docker plugin create with same names
This fix tries to fix the issue raised in 28684:
1. Duplicate plugin create with the same name will override the old plugin reference
2. In case an error happens in the middle of the plugin creation, plugin directories
   in `/var/lib/docker/plugins` are not cleaned up.

This fix update the plugin store so that `Add()` will return an error if a plugin
with the same name already exist.

This fix also will clean up the directory in `/var/lib/docker/plugins` in case
an error happens in the middle of the plugin creation.

This fix fixes 28684.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 662d456928e47162a3af5931356cb05b6a3f9918
Component: engine
2016-11-28 12:37:49 -08:00
e24e6d4206 Merge pull request #27467 from tonistiigi/attach-cb
Move stdio attach from libcontainerd backend to callback
Upstream-commit: 8ed31089c03c36954e95c2066b1f3724e2d5c849
Component: engine
2016-10-25 16:23:07 +02:00
9a299b360f Make experimental a runtime flag
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: 7781a1bf0fef748877326632b88e92fbf3c90daa
Component: engine
2016-10-24 15:20:01 -07:00
1883869e16 Move stdio attach from libcontainerd backend to callback
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 37a3be2449d2a314305615ffcc287a598a829dba
Component: engine
2016-10-24 00:20:36 -07:00
6363780a38 Remove restartmanager from plugins
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: a452d1fccb6d515545dacd4bebfa36cbf70a6535
Component: engine
2016-10-07 12:10:13 -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
2f08c46e47 Adding pluginv2 support for libnetwork (part 1)
Legacy plugins (aka pluginv1) calls in libnetwork are replaced with
calls using the new plugin model (aka pluginv2). pkg/plugins is still
used for managing the http client connections to the plugin.

This commit makes the necessary changes in docker/docker. Part 2 will
will take care of the libnetwork changes.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 17b8aba1d924e505563af400d758b89c8406961d
Component: engine
2016-09-06 14:30:55 -07:00
ec70ce176c Reorganize plugin package into sub packages.
Split plugin package into `store` and `v2/plugin`. Now the functionality
is clearly delineated:
- Manager: Manages the global state of the plugin sub-system.
- PluginStore: Manages a collection of plugins (in memory and on-disk)
- Plugin: Manages the single plugin unit.

This also facilitates splitting the global PluginManager lock into:
- PluginManager lock to protect global states.
- PluginStore lock to protect store states.
- Plugin lock to protect individual plugin states.

Importing "github.com/docker/docker/plugin/store" will provide access
to plugins and has lesser dependencies when compared to importing the
original monolithic `plugin package`.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 27a55fba28ff9c085385254cb69ecc8ea6891aa9
Component: engine
2016-08-27 11:08:08 -07:00
67ccfbdecc Merge pull request #25424 from vieux/enabled
replace active by enabled for consistency in plugins
Upstream-commit: ed0dff8f16716b4f6debfc191124e98750dd05bb
Component: engine
2016-08-26 15:22:41 -07:00
e44f33953e replace active by enabled for consistency in plugins
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: cf4e268115911e9e4a4da94dc00b2dc370f86a47
Component: engine
2016-08-25 20:42:49 -07:00
9f32495eeb Cleanup fallback to V1 plugins logic.
handleLegacy is a flag to indicate whether daemon is supporting legacy
plugins. When the time comes to remove support for legacy plugins,
flipping this bool is all that will be needed to remove legacy plugin
support. This can be a global variable rather than be embedded in the
manager, thereby cleaning up code.

Also rename to allowV1PluginsFallback for clarity.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 031a2a5c4b58a153e6e76a573abfa6359d1c321a
Component: engine
2016-08-25 11:39:47 -07:00
78f61f4f99 Make docker volume list lookup plugins installed using new model.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 59c45f7c0a5ba183f393e61e7ca7597809463410
Component: engine
2016-08-17 13:27:43 -07:00
be73319004 When handling plugin exit, lookup plugins only during daemon shutdown.
The main intent of handling plugin exit is for graceful shutdown
of plugins during daemon shutdown. So avoid plugin lookup during
plugin exits caused by other reasons (eg. force remove)

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 57499fa62e697ea244455c5abda7ed8bc022f44c
Component: engine
2016-08-15 14:46:02 -07:00
cb1c855c27 Merge pull request #23951 from allencloud/defer-os-file-close
add defer file.Close to avoid potential fd leak
Upstream-commit: 64605d709f9bf5677d513d6ed78d63fffadc697d
Component: engine
2016-08-10 11:07:15 -07:00
1c502571ef add defer file.Close to avoid potential fd leak
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 0ead624473b6bddc232b46bc7c76ab4f9c743ff5
Component: engine
2016-08-10 08:36:09 +08:00
2921fa6d1b fix plugin restart on docker restart
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: ab12ed4a5642edb4d96b54b6152f12260093f3ea
Component: engine
2016-08-09 11:49:28 -07:00
fb8eea7ff0 Merge pull request #25096 from vieux/docker_plugin_remove_force
Add --force to docker plugin remove
Upstream-commit: 85428a1a53292684be55de9de3646e8c4745c72e
Component: engine
2016-08-05 14:45:05 +02:00
d5f439ee89 Add --force to docker plugin remove
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: 0016b331dac94661678fd7676c7b6ccc9ec2d147
Component: engine
2016-08-04 15:55:45 -07:00
3ef890484a fix deadlock when more than 1 plugin is installed
Signed-off-by: Victor Vieux <vieux@docker.com>
Upstream-commit: 42360d164b9f25fb4b150ef066fcf57fa39559a7
Component: engine
2016-08-03 16:22:12 -07:00
99b9e36eb0 Remove plugin root from filesystem.
`docker plugin remove` didnt actually remove plugin from disk. Fix that.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 5690730a7471726bbaf813e634a7117a562dfb8c
Component: engine
2016-08-01 10:46:50 -07:00
062b507351 Make daemon events listen for plugin lifecycle events.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 42abccb841b5bc0d420044e69165852b0054c38f
Component: engine
2016-07-26 10:51:47 -07:00
ed21a7262c Handle plugin shutdown when liveRestore is set.
When daemon has liveRestore set, daemon shutdown should not shutdown
plugins. Fixes #24759

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 4a44cf1d4c8e540b67aaa3834291a964c6ab7524
Component: engine
2016-07-22 15:26:43 -07: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
0633dc391e Remove use of exec-root in plugins due to socket pathname limits.
Unix sockets are limited to 108 bytes. As a result, we need to be
careful in not using exec-root as the parent directory for pluginID
(which is already 64 bytes), since it can result in socket path names
longer than 108 bytes. Use /tmp instead. Before this change, setting:
- dockerd --exec-root=/go/src/github.com/do passes
- dockerd --exec-root=/go/src/github.com/doc fails
After this change, there's no failure.

Also, write a volume plugins test to verify that the plugins socket
responds.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 21ecd5a93db34288c0c579d5738030716d7bef2d
Component: engine
2016-07-15 09:17:29 -07:00
1da671b499 Merge pull request #24229 from anusha-ragunathan/shutdown-plugins
Shutdown plugins during daemon shutdown.
Upstream-commit: b91e2dd9942f4c34b62de37c3862b9febd270b22
Component: engine
2016-07-11 22:14:50 -04:00
495149133d Shutdown plugins during daemon shutdown.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 863ab9ab134d0baef3c7e5d745eded891e87e734
Component: engine
2016-07-11 14:21:27 -07:00
9c0555f6e0 add a whitespace in plugin's logging
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 97c77b7e0dd2eef23beca1180be93733a3a95e82
Component: engine
2016-07-04 09:38:06 +08:00
e1b43ae16a add err handling, close fd
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 2281ce7e98ec983514450c33c0ef1d90262c3b4f
Component: engine
2016-06-27 23:51:54 +08:00
4552e85448 plugins: fix name handling for legacy plugins
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 8ba17b4823f9a1a40a405905613667d97bb24546
Component: engine
2016-06-17 12:02:05 -07:00
089ba4264f Update plugin command with defaulttag
This way, you don't have to specify the ":latest" tag for some command
and not for others

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: cb321e82db662f5190a6d83a90677a9dd9fdcd31
Component: engine
2016-06-17 10:18:18 -07:00
bc663a35ec plugins: remove automatic mounting of a state dir
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 15ff9de65801178a522c445ff9fb8964e21d12a0
Component: engine
2016-06-17 10:03:30 -07:00
f06eb442e7 Implement plugin restore after daemon restart
This ensures that:

- The in-memory plugin store is populated with all the plugins
- Plugins which were active before daemon restart are active after.
  This utilizes the liverestore feature when available, otherwise it
  manually starts the plugin.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: dfd91873056c172ffc061d882da0cd18204b521a
Component: engine
2016-06-15 13:39:33 -04:00
cb7a4630c6 Fix removing plugins
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 5e156fd3d4b21267caca093dd0df7ed6bce85535
Component: engine
2016-06-15 11:21:31 -04: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