Commit Graph

97 Commits

Author SHA1 Message Date
d491895d0a Fix issue reloading mount options on restart
On daemon restart the local volume driver will read options that it
persisted to disk, however it was reading an incorrect path, causing
volume options to be silently ignored after a daemon restart.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: c560dd968600ebc9c1ff78f256ee93a6ded9a728
Component: engine
2016-08-01 23:30:39 -04:00
e347f2b7f4 delete a useless variable
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: 87cada6d7f62589ce77dc0557ad97f4140b49c70
Component: engine
2016-07-29 15:34:21 +08:00
57c5690493 optimize a print in
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update 'optimize-a-print'

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: a503f3ac2fdb5f24b7ca982fc6447423095f229e
Component: engine
2016-07-28 19:20:20 +08:00
1c3431e16a fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 4e959ef2f7f063803d04e06166f459257eb94b5c
Component: engine
2016-07-23 11:32:23 +08:00
acb2cc6fda Change mount-types to lowercase
these values were changed to lowercase in
690cb2d08c,
but not changed accordingly in docker/docker.

this changes the mounttypes to lowercase

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 8f93128cd619e1d11be1bc0ae21f1362b1e3f9ad
Component: engine
2016-07-21 11:25:42 +02:00
f139b64ef8 Remove extra map lookup for volume drivers.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 5d4627331ee0c685116b083e9f25f2644f0d1bd0
Component: engine
2016-07-19 09:35:56 -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
20cc8c8ee0 Remove code duplication in VolumeStore Create CreateWithRef
Signed-off-by: Mauricio Garavaglia <mauricio@medallia.com>
Upstream-commit: b65d6927d48028834a7ff9ea8150225ca0d48920
Component: engine
2016-07-06 19:09:47 -03:00
38e9398cfc fixes minor typo in comment
Signed-off-by: Robert Terhaar <rterhaar@atlanticdynamic.com>
Upstream-commit: 29fea0fd2e9970eb5df0feb0ebef41c5425295f0
Component: engine
2016-07-01 17:29:08 -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
be63983b3a Add Swarm management backend
As described in our ROADMAP.md, introduce new Swarm management API
endpoints relying on swarmkit to deploy services. It currently vendors
docker/engine-api changes.

This PR is fully backward compatible (joining a Swarm is an optional
feature of the Engine, and existing commands are not impacted).

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Victor Vieux <vieux@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Signed-off-by: Madhu Venugopal <madhu@docker.com>
Upstream-commit: 534a90a99367af6f6bba1ddcc7eb07506e41f774
Component: engine
2016-06-13 22:16:18 -07:00
74d1f25f8f Merge pull request #23002 from Microsoft/jjh/readonly
Windows: Support RO volumes 14350+
Upstream-commit: 393e97e435e7c1629934d8042d1fb8e5bb7d61f9
Component: engine
2016-06-08 11:18:48 -07:00
9ca189a13d Windows: Support RO volumes 14350+
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 8d174a43babd19e8c1166338b5aa5f1128914a96
Component: engine
2016-06-07 14:55:36 -07: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
ab8e2e8aee Need to create bind mount volume if it does not exist.
In order to be consistent on creation of volumes for bind mounts
we need to create the source directory if it does not exist and the
user specified he wants it relabeled.

Can not do this lower down the stack, since we are not passing in the
mode fields.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
Upstream-commit: 322cc99c6962ecb56be3107061eb7f61364d05f8
Component: engine
2016-06-02 07:14:17 -04:00
3a35464d9d Get the Docker Engine to build clean on Solaris
Signed-off-by: Amit Krishnan <krish.amit@gmail.com>
Upstream-commit: 86d8758e2bb5e9d21d454ceda90b33feb8e74771
Component: engine
2016-05-23 16:37:12 -07:00
ecdf06bd1f Enable auto-creation of host-path on Windows
Auto-creation of host-paths has been un-deprecated,
so to have feature-parity between Linux and Windows,
this feature should also be present on Windows.

This enables auto-creation on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 4e080347af657ca3a0c103c6bc6cd6a8157d20d8
Component: engine
2016-05-07 00:55:16 +02: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
8cd702acc5 Merge pull request #22065 from thaJeztah/remove-deprecation-message
Remove deprecation warning
Upstream-commit: 4e898ae64be25bc5a86e0e7865a37b9f596e4d17
Component: engine
2016-04-18 15:29:05 -04:00
23c1fd9d95 Merge pull request #21006 from cpuguy83/volume_inspect_meta
Allow volume drivers to provide a `Status` field
Upstream-commit: e40e5b97c1ad540aa0be568467546f27932ef3a5
Component: engine
2016-04-15 18:53:39 +02:00
ed92db4f93 Allow volume drivers to provide a Status field
The `Status` field is a `map[string]interface{}` which allows the driver to pass
back low-level details about the underlying volume.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 36a1c56cf555f8fe9ceabeebb8fc956e05863fc7
Component: engine
2016-04-15 10:56:38 -04:00
18bcaaee70 Remove deprecation warning
Auto-creation of non-existing host directories
is no longer deprecated (9d5c26bed2ac287542e176d9149250927876e3f5),
so this warning is no longer relevant.

This removes the deprecation warning.

Also removes the "system" package here, because it's only used
on non-Windows, so basically just called os.MkdirAll()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 1d02ad2a519765179480e0ae113bcf510a2713af
Component: engine
2016-04-15 13:57:19 +02:00
e7d2e352a6 Merge pull request #22022 from AkihiroSuda/fixunused
Clean up unused code
Upstream-commit: 9e4b5e06f0618a9feca3ab07b1b4a6c6fde05409
Component: engine
2016-04-14 12:21:47 -07:00
c47b0699eb Clean up unused code
Signed-off-by: Akihiro Suda <suda.kyoto@gmail.com>
Upstream-commit: d231260868507174d60ff58b18b14fa5bc2d5b66
Component: engine
2016-04-14 07:04:10 +00:00
1442a95a2d Fix N+1 calling Path() on volume ls
Implements a `CachedPath` function on the volume plugin adapter that we
call from the volume list function instead of `Path.
If a driver does not implement `CachedPath` it will just call `Path`.

Also makes sure we store the path on Mount and remove the path on
Unmount.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 9e6b1852a78eda6ed2cb255d6be8a0d0e5a5ca40
Component: engine
2016-04-12 20:30:34 -04:00
86ed4f4024 Windows: Remove TP4 support from test code
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: b0e24c73931d70ef543a3d69c41b0add7130cb80
Component: engine
2016-04-11 15:36:31 -07:00
403d945979 volume/store: fix couple of races with accessing maps
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: e6d87c0706d178407ffccaab5c3ffc13a9e7b02e
Component: engine
2016-03-29 10:46:29 -07:00
678cdd4ebe fix race condition between list and remove volume
This was done by making List not populate the cache.

fixes #21403

Signed-off-by: Viktor Stanchev <me@viktorstanchev.com>
Upstream-commit: 800b9c5a2698aae5c43f42d4c9c1a41280b556a6
Component: engine
2016-03-24 11:37:18 -07:00
11df489bb4 Merge pull request #21400 from LK4D4/fix_volumes_race
volume/local: fix race in List
Upstream-commit: 2ec1764d45de9269522cb084ec87c87dd6f3c4e0
Component: engine
2016-03-22 14:29:12 -07:00
02220a45c4 Merge pull request #21270 from ehazlett/resource-labels
Add Label support for Images (build), Networks and Volumes on Creation
Upstream-commit: 53d2e5e9d754ce8fbef733759e9ec450514133e3
Component: engine
2016-03-22 15:12:33 -04:00
efc6c29e8f volume/local: fix race in List
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 3536c09ceaa2d94a43a3a3228b096ba7a61f558d
Component: engine
2016-03-22 11:21:38 -07:00
fe56b4ef22 add label support for build, networks and volumes
build: implement --label

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

network: allow adding labels on create

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

volume: allow adding labels on create

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

add tests for build, network, volume

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

vendor: libnetwork and engine-api bump

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
Upstream-commit: fc214b4408d915e3510f61c7584ca01c176d1373
Component: engine
2016-03-22 11:49:06 -04:00
308c81e7d4 Add explicit flags for volume cp/no-cp
This allows a user to specify explicitly to enable
automatic copying of data from the container path to the volume path.
This does not change the default behavior of automatically copying, but
does allow a user to disable it at runtime.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b0ac69b67ef79c6c937f84bee3df20a1924ad334
Component: engine
2016-03-21 20:38:44 -04:00
16d6520e91 fix some typos.
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 34b82a69b94ef9c7913e2809ae918e6f4331201e
Component: engine
2016-03-10 10:09:27 +08:00
c3e3a8fbbe Merge pull request #20901 from HackToday/buildimage
Fix the driver name empty case
Upstream-commit: 89d950303c4156a38f0bdb8e054acaa56e02aa47
Component: engine
2016-03-03 18:44:33 +01:00
8bbce28a1d Support mount opts for local volume driver
Allows users to submit options similar to the `mount` command when
creating a volume with the `local` volume driver.

For example:

```go
$ docker volume create -d local --opt type=nfs --opt device=myNfsServer:/data --opt o=noatime,nosuid
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b05b2370757d7143d761e5e6abb8c0f9b009f737
Component: engine
2016-03-03 10:32:25 -05:00
b8ad7b3170 Fix the driver name empty case
As drivername maybe "" in hostconfig, so we should not
directly print dirvername with var drivername,
instead, we use the real driver name property to print it.

Fixes: #20900
Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
Upstream-commit: 6c78edaf7f22bfe3bd731855f767b9fa3c7d8549
Component: engine
2016-03-03 07:42:28 +00:00
e630a6085a Windows CI: Unit Test turn off TestRemove
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: de6939817d20f5c2a370efc9eb207e3e8c897520
Component: engine
2016-02-29 08:57:30 -08:00
b2ac99b3fa Remove static errors from errors package.
Moving all strings to the errors package wasn't a good idea after all.

Our custom implementation of Go errors predates everything that's nice
and good about working with errors in Go. Take as an example what we
have to do to get an error message:

```go
func GetErrorMessage(err error) string {
	switch err.(type) {
	case errcode.Error:
		e, _ := err.(errcode.Error)
		return e.Message

	case errcode.ErrorCode:
		ec, _ := err.(errcode.ErrorCode)
		return ec.Message()

	default:
		return err.Error()
	}
}
```

This goes against every good practice for Go development. The language already provides a simple, intuitive and standard way to get error messages, that is calling the `Error()` method from an error. Reinventing the error interface is a mistake.

Our custom implementation also makes very hard to reason about errors, another nice thing about Go. I found several (>10) error declarations that we don't use anywhere. This is a clear sign about how little we know about the errors we return. I also found several error usages where the number of arguments was different than the parameters declared in the error, another clear example of how difficult is to reason about errors.

Moreover, our custom implementation didn't really make easier for people to return custom HTTP status code depending on the errors. Again, it's hard to reason about when to set custom codes and how. Take an example what we have to do to extract the message and status code from an error before returning a response from the API:

```go
	switch err.(type) {
	case errcode.ErrorCode:
		daError, _ := err.(errcode.ErrorCode)
		statusCode = daError.Descriptor().HTTPStatusCode
		errMsg = daError.Message()

	case errcode.Error:
		// For reference, if you're looking for a particular error
		// then you can do something like :
		//   import ( derr "github.com/docker/docker/errors" )
		//   if daError.ErrorCode() == derr.ErrorCodeNoSuchContainer { ... }

		daError, _ := err.(errcode.Error)
		statusCode = daError.ErrorCode().Descriptor().HTTPStatusCode
		errMsg = daError.Message

	default:
		// This part of will be removed once we've
		// converted everything over to use the errcode package

		// FIXME: this is brittle and should not be necessary.
		// If we need to differentiate between different possible error types,
		// we should create appropriate error types with clearly defined meaning
		errStr := strings.ToLower(err.Error())
		for keyword, status := range map[string]int{
			"not found":             http.StatusNotFound,
			"no such":               http.StatusNotFound,
			"bad parameter":         http.StatusBadRequest,
			"conflict":              http.StatusConflict,
			"impossible":            http.StatusNotAcceptable,
			"wrong login/password":  http.StatusUnauthorized,
			"hasn't been activated": http.StatusForbidden,
		} {
			if strings.Contains(errStr, keyword) {
				statusCode = status
				break
			}
		}
	}
```

You can notice two things in that code:

1. We have to explain how errors work, because our implementation goes against how easy to use Go errors are.
2. At no moment we arrived to remove that `switch` statement that was the original reason to use our custom implementation.

This change removes all our status errors from the errors package and puts them back in their specific contexts.
IT puts the messages back with their contexts. That way, we know right away when errors used and how to generate their messages.
It uses custom interfaces to reason about errors. Errors that need to response with a custom status code MUST implementent this simple interface:

```go
type errorWithStatus interface {
	HTTPErrorStatusCode() int
}
```

This interface is very straightforward to implement. It also preserves Go errors real behavior, getting the message is as simple as using the `Error()` method.

I included helper functions to generate errors that use custom status code in `errors/errors.go`.

By doing this, we remove the hard dependency we have eeverywhere to our custom errors package. Yes, you can use it as a helper to generate error, but it's still very easy to generate errors without it.

Please, read this fantastic blog post about errors in Go: http://dave.cheney.net/2014/12/24/inspecting-errors

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: a793564b2591035aec5412fbcbcccf220c773a4c
Component: engine
2016-02-26 15:49:09 -05:00
661cc031a6 Fix panic when plugin responds with null volume
In cases where the a plugin responds with both a null or empty volume
and a null or empty Err, the daemon would panic.
This is because we assumed the idiom if `err` is nil, then `v` must not
be but in reality the plugin may return whatever it wants and we want to
make sure it doesn't harm the daemon.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 96c79a1934dd52d2a6f648e519b5d4ac60ac8ca1
Component: engine
2016-02-24 20:45:38 -05:00
5b28f437b0 Fix issue with multiple volume refs with same name
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 0fe31306d1c1c93c4ef33654f7a37932296cf8a6
Component: engine
2016-02-16 21:46:13 -05:00
98ffe8be11 Merge pull request #20198 from cpuguy83/check_drivers_b4_vol_create
Check drivers before vol create
Upstream-commit: 79edcc517231e46d1fa9e03081488527143eefae
Component: engine
2016-02-12 18:41:48 -05: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
91c83926d7 Remove back-compat hacks from for volume plugins.
Hacks were added as interim support for 1.10 but should not be needed
for 1.11.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 3403a01b07a73defe9f15c30e16ec8dfcab50439
Component: engine
2016-02-10 20:43:20 -05:00
13ec79c31c Probe all drivers if volume driver not specified
This fixes an issue where `docker run -v foo:/bar --volume-driver
<remote driver>` -> daemon restart -> `docker run -v foo:/bar` would
make a `local` volume after the restart instead of using the existing
volume from the remote driver.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 00ec6102d993a752bd8dfb4ee393a4e58e59a4fe
Component: engine
2016-02-10 20:43:15 -05:00
4075818bf4 Fix volume driver API compatibility mode (a little)
Signed-off-by: Stephen Rust <srust@blockbridge.com>
Upstream-commit: c3985bdf797a4526eac5fb0bd92047ac0f8513d9
Component: engine
2016-02-08 23:12:29 -05:00
debd24d25b fix dead lock in volume store dereference
Signed-off-by: Pei Su <sillyousu@gmail.com>
Upstream-commit: f5310652d30e72fe88a3edc70b2911397c28b7e4
Component: engine
2016-01-27 16:34:10 +08:00
92c9319930 Merge pull request #19671 from calavera/volume-dangling
Make volume dangling filter return only used volumes with `dangling=false`.
Upstream-commit: 146e49b039c59107cc31de734f0bf5d4604c04d9
Component: engine
2016-01-26 17:01:20 -05:00
360e6f6c70 Merge pull request #19568 from cpuguy83/17907_fix_rmv
On container rm, don't remove named mountpoints
Upstream-commit: 58c2488d07f4c984c853ca4b4a5c86b55c4c784c
Component: engine
2016-01-25 18:13:57 -08:00