Commit Graph

68 Commits

Author SHA1 Message Date
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
9d1352af0d Make volume dangling filter return only used volumes with dangling=false.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1431b623a4809ec3992a357387037366ab083548
Component: engine
2016-01-25 16:26:51 -05:00
7e07ac8939 On container rm, don't remove named mountpoints
This makes it so when calling `docker run --rm`, or `docker rm -v`, only
volumes specified without a name, e.g. `docker run -v /foo` instead of
`docker run -v awesome:/foo` are removed.

Note that all volumes are named, some are named by the user, some get a
generated name. This is specifically about how the volume was specified
on `run`, assuming that if the user specified it with a name they expect
it to persist after the container is cleaned up.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: dd7d1c8a02d8693aa4f381f82c5bbdcad9a5ff58
Component: engine
2016-01-25 15:51:28 -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
edde0f73ca Use fine-grained locks for plugin loading.
This helps ensure that only one thing is trying to intialize a plugin at
once while also keeping the global lock free during initialization.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: cfb2c667ad0bb17d9a1bd49a294d5c38e4cbf040
Component: engine
2016-01-20 13:57:52 -05:00
7d383f2b5f On create, copy image data for named volumes.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b4683327074d193428c724b153e8848ef2068c1d
Component: engine
2016-01-07 21:57:08 -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
26657d68aa update volume name regex
Disallow creating a volume starting with a /.

Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: b46f044bf71309088b30c1172d4c69287c6a99df
Component: engine
2016-01-04 15:00:49 -08:00
7bea2a5a61 Move volume.SplitN() to the one place it is used in runconfig.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: c5a2fdb697e403af228a68d08c68d17d347f6cf3
Component: engine
2016-01-04 12:06:30 -05:00
3f495d0416 Fix downstream client API build errors on Solaris
The client API at fsouza/go-dockerclient has dependencies on packages in
the docker/docker repository which currently do not build on Solaris. In
particular, stat_unsupported.go makes use of the Mtimespec field of the
syscall.Stat_t struct, which is not present on Solaris, and a number of
Unix-specific packages do not list Solaris in their compile targets.

This commit adds enough support to be able to build
fsouza/go-dockerclient on SmartOS using Go 1.5.1 without affecting other
platforms.

Signed-off-by: James Nugent <james@jen20.com>
Upstream-commit: c12dbb8c82457a58e209302bf9752aec64234404
Component: engine
2015-12-30 18:25:42 -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
c127109fa3 volume: store: store.go: remove debug message
When driver is `local` an empty string is given to the debug message.
This patch removes the debug statement.

```
Dec 20 19:07:01 localhost.localdomain docker[19734]:
time="2015-12-20T19:07:01.872021857+01:00" level=debug msg="Registering
new volume reference: driver , name
c2291b964b4d7b1b51ec51d2ccfe2544f83fd23404709225a43743c5faadad55"
```

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 23a18b5f93b4dfbed419509589687220e5aff487
Component: engine
2015-12-21 19:14:27 +01:00
2a2006ef18 Merge pull request #17034 from rhvgoyal/volume-propagation
Capability to specify per volume mount propagation mode
Upstream-commit: ce0b1841c82b6972d96654e083f813944e72443f
Component: engine
2015-12-15 12:14:41 -05:00
a1551674ac Add some unit and integration tests
Add a unit test and couple of integration tests for volume propagation.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: f988c98ff318dcfecb9d2db9511fe78e70b43e44
Component: engine
2015-12-14 10:39:53 -05:00
c0860c6bed Add capability to specify mount propagation per volume
Allow passing mount propagation option shared, slave, or private as volume
property.

For example.
docker run -ti -v /root/mnt-source:/root/mnt-dest:slave fedora bash

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: a2dc4f79f260247afe55ab7117c9de02a769d883
Component: engine
2015-12-14 10:39:53 -05:00
3c4fcf6b7a Fix typos found across repository
Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
Upstream-commit: 927b334ebfc786276a039e45ec097e71bf9a104c
Component: engine
2015-12-13 18:04:12 +02:00
89ca8a3104 Fix spelling of 'existent'
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Upstream-commit: 899caaca9c990067d541231c6d288de89dbb79e7
Component: engine
2015-11-25 13:45:37 +00:00
b104ad8df6 Remove the container initializers per platform.
By removing deprecated volume structures, now that windows mount volumes we don't need a initializer per platform.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 060f4ae6179b10aeafa883670826159fdae8204a
Component: engine
2015-11-18 08:41:46 -05:00
3e26fccb77 Supported added for reterving Plugin list for Network and Volume.
Also, plugin information in docker info output.

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
Upstream-commit: aa7fd884e609d3d13df628600a1799e0e76444e9
Component: engine
2015-11-16 15:28:09 +09:00
82dda06a38 Windows: Pass store test-unit
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 32b905d90ff133c92bb0dd89207a68c45fc81bbd
Component: engine
2015-11-13 12:39:43 -08:00
cb403bcf07 Refactor volume store's error usage
Uses an errors API similar the `net` package.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 43012fe8425650930a21703d9468ab0e777e053a
Component: engine
2015-11-10 20:33:29 -05:00
aaf8bba9c2 Merge pull request #17185 from cpuguy83/use_finer_locking_for_volume_store
Fix potential races in the volume store
Upstream-commit: cc207aa136fd5e01164d245de94fb900ca7212a2
Component: engine
2015-11-06 08:48:12 -08:00
365046209e Fix potential races in the volume store
Uses finer grained locking so that each volume name gets its own lock
rather than only being protected by the global lock, which itself needs
to be unlocked during cetain operations (`create` especially`)

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: fe66fdd18c0307cc02e6aeff8625c179452b8436
Component: engine
2015-11-04 16:59:47 -05:00
dd17d17d3e Fix volume error messages
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 5f4cb33a5186c7822dc718ba915f59979c598c28
Component: engine
2015-10-28 09:23:43 -07:00
f7f7ce4926 Windows: Add volume support
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: a7e686a779523100a092acb2683b849126953931
Component: engine
2015-10-22 10:42:53 -07:00
f1b2a78ca3 Move volume name validation to the local driver.
Delegate validation tasks to the volume drivers. It's up to them
to decide whether a name is valid or not.
Restrict volume names for the local driver to prevent creating
mount points outside docker's volumes directory.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: d6d60287ee3a8a064340582d65c131181ae77127
Component: engine
2015-10-21 12:28:26 -04: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
f079e61160 Merge pull request #16493 from cpuguy83/doc_plugin_rpcgen
Add README for pluginrpc-gen
Upstream-commit: 8f7f0f8deb95804eef95b572c53721ea1d0199d9
Component: engine
2015-09-23 15:36:05 -04:00
b761cfeb67 Add README for pluginrpc-gen
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 7acd3ca79d2b13500ca3f53a567cb87fddd4a543
Component: engine
2015-09-22 19:34:44 -04:00
5a458f78ee Move volume ref counting store to a package.
- Add unit tests to make sure the functionality is correct.
- Add FilterByDriver to allow filtering volumes by driver, for future
  `volume ls` filtering and whatnot.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 72bb56618b522fc3cece7cfd706c56296824673d
Component: engine
2015-09-21 12:46:49 -04:00