Commit graph

171 commits

Author SHA1 Message Date
David Sheets
f13297c0be Add 'consistent', 'cached', and 'delegated' mode flags
This adds 'consistency' mode flags to the mount command line argument.
Initially, the valid 'consistency' flags are 'consistent', 'cached',
'delegated', and 'default'.

Signed-off-by: David Sheets <dsheets@docker.com>
Signed-off-by: Jeremy Yallop <yallop@docker.com>
2017-03-01 18:13:47 +00:00
allencloud
1d1362bdb2 sort volume drivers and auth plugins in info response
Signed-off-by: allencloud <allen.sun@daocloud.io>
2017-02-01 12:01:49 +08:00
Adam Eijdenberg
8bad0ab139 Fixup use of Error() with format string to use Errorf()
Signed-off-by: Adam Eijdenberg <adam.eijdenberg@gmail.com>
2017-01-28 22:46:56 +11:00
Alexander Morozov
541150da53 Merge pull request #29428 from rhatdan/selinux
We need to fix labels if the user requests on volumes
2017-01-26 11:47:14 -08:00
Akihiro Suda
4a8799dc0a validate mount path for tmpfs
There was no validation for `docker run --tmpfs foo`.

In this PR, only two obvious rules are implemented:
 - path must be absolute
 - path must not be "/"
We should add more rules carefully.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-01-20 06:01:48 +00:00
Sebastiaan van Stijn
5eda0c5947 Merge pull request #28925 from daehyeok/ineffassign
Refactoring ineffectual assignments
2017-01-18 15:01:57 +01:00
Vincent Demeester
fa4f09194f Merge pull request #28690 from zteBill/volume-errorinfo-inexact
repeated volume create information
2017-01-15 17:10:27 +01:00
Daehyeok Mun
6306019d0b Refactoring ineffectual assignments
This patch fixed below 4 types of code line
1. Remove unnecessary variable assignment
2. Use variables declaration instead of explicit initial zero value
3. Change variable name to underbar when variable not used
4. Add erro check and return for ignored error

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2017-01-13 00:27:01 -07:00
Dan Walsh
0c791c8e9f We need to fix labels if the user requests on volumes
Currently local volumes and other volumes that support SELinux do
not get labeled correctly.  This patch will allow a user to specify
:Z or :z when  mounting a volume and have it fix the label of the newly
created volume.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2017-01-10 09:39:31 -05:00
Vincent Demeester
9c96768eae Merge pull request #29564 from aaronlehmann/getter-types
plugingetter: Avoid all caps for constant declarations
2017-01-10 09:35:19 +01:00
Josh Eveleth
eee0cfa45d Fix minor typo
Signed-off-by: Josh Eveleth <joshe@opendns.com>
2017-01-05 12:45:56 -08:00
Vincent Demeester
7ad34996bc Merge pull request #29903 from Microsoft/jjh/volumetest-tp5
Windows: Fix TP5 volume unit tests TODOs
2017-01-05 09:53:31 +01:00
John Howard
cc3e59c44e Windows: Fix old TP5 volume unit tests
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-01-04 16:17:55 -08:00
John Howard
c2246f28f6 Correct comment in vol driver interface
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-01-04 12:06:37 -08:00
Aaron Lehmann
428600108c plugingetter: Avoid all caps for constant declarations
Go style calls for mixed caps instead of all caps:
https://golang.org/doc/effective_go.html#mixed-caps

Change LOOKUP, ACQUIRE, and RELEASE to Lookup, Acquire, and Release.

This vendors a fork of libnetwork for now, to deal with a cyclic
dependency issue. The change will be upstream to libnetwork once this is
merged.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-01-04 10:19:04 -08:00
Tonis Tiigi
3d86b0c79b 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>
2016-12-23 13:29:58 -08:00
Anusha Ragunathan
d25186a625 Merge pull request #29664 from cpuguy83/fix_bolt_usage
Fix usage of boltdb in volume restore
2016-12-22 13:53:04 -08:00
Brian Goff
4876a9047e Fix usage of boltdb in volume restore
bolt k/v pairs are only valid for the life of a transaction.
This means the memory that the k/v pair is referencing may be invalid if
it is accessed outside of the transaction.
This can potentially cause a panic.

For reference: https://godoc.org/github.com/boltdb/bolt#hdr-Caveats

To fix this issue, unmarshal the stored data into volume meta before
closing the transaction.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-12-22 11:56:02 -05:00
Sebastiaan van Stijn
b9ee31ae02 Merge pull request #29314 from vdemeester/no-more-utils
Remove the utils package
2016-12-22 15:21:05 +01:00
Vincent Demeester
dba271a42a
Move names to package api
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-12-21 22:42:47 +01:00
Vincent Demeester
eb59c6d587 Merge pull request #29378 from aaronlehmann/swarm-plugins
Support v2 plugins in swarm mode
2016-12-19 11:07:06 +01:00
Sebastiaan van Stijn
2121041944 Merge pull request #29423 from unclejack/api_cli_integ_return
return directly without ifs in remaining packages
2016-12-17 21:30:47 +01:00
Aaron Lehmann
53d447c5d5 Fix volume Create to check against canonical driver name
Previously, it was comparing against the driver name passed in by the
caller. This could lead to subtle issues when using plugins, like
"plugin" vs. "plugin:latest".

Also, remove "conflict:" prefix to improve the error message.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-12-16 10:45:46 -08:00
Brian Goff
6ef1060cd0 Fix volume plugin refecounting on daemon restart
Ensures all known volumes (known b/c they are persisted to disk) have
their volume drivers refcounted properly.

In testing this, I found an issue with `--live-restore` (required since
currently the provided volume plugin doesn't keep state on restart)
where restorted plugins did not have a plugin client loaded causing a
panic when trying to use the plugin.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-12-16 10:14:06 -05:00
unclejack
2c187a24e0 return directly without ifs in remaining packages
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2016-12-14 23:28:27 +02:00
Brian Goff
f29bbd16f5 Refcount graphdriver plugins properly
Adds 2 new methods to v2 plugin `Acquire` and `Release` which allow
refcounting directly at the plugin level instead of just the store.
Since a graphdriver is initialized exactly once, and is really managed
by a separate object, it didn't really seem right to call
`getter.Get()` to refcount graphdriver plugins.
On shutdown it was particularly weird where we'd either need to keep a
driver reference in daemon, or keep a reference to the pluggin getter in
the layer store, and even then still store extra details on if the
graphdriver is a plugin or not.

Instead the plugin proxy itself will handle calling the neccessary
refcounting methods directly on the plugin object.

Also adds a new interface in `plugingetter` to account for these new
functions which are not going to be implemented by v1 plugins.

Changes terms `plugingetter.CREATE` and `plugingetter.REMOVE` to
`ACQUIRE` and `RELEASE` respectively, which seems to be better
adjectives for what we're doing.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-12-09 19:46:28 -05:00
Anusha Ragunathan
0a072e93df Merge pull request #26398 from tiborvass/plugin-fixes
plugins: container-rootfs-relative paths
2016-12-09 12:48:59 -08:00
Tibor Vass
c54b717caf 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>
2016-12-09 10:16:24 -08:00
yuexiao-wang
11454e1c97 Fix a bit typos
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2016-12-09 03:05:11 +08:00
Aaron Lehmann
a762222396 volume: Use a map of maps for VolumeStore.refs
The current implementation of getRefs is a bit fragile. It returns a
slice to callers without copying its contents, and assumes the contents
will not be modified elsewhere.

Also, the current implementation of Dereference requires copying the
slice of references, excluding the one we wish to remove.

To improve both of these things, change refs to be a map of maps.
Deleting an item becomes trivial, and returning a slice of references
necessitates copying from the map.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-12-05 15:39:05 -08:00
Victor Vieux
42aafe725f Merge pull request #28994 from cpuguy83/allow_vol_recreate_for_same_driver
Fix out-of-band vol delete+create for same driver
2016-12-02 15:12:13 -08:00
lixiaobing10051267
b3e5137856 check testing code for runconfig and volume
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
2016-12-01 17:07:38 +08:00
Brian Goff
d8ce4a6e10 Fix out-of-band vol delete+create for same driver
Fix issue where out-of-band deletions and then a `docker volume create`
on the same driver caused volume to not be re-created in the driver but
return as created since it was stored in the cache.

Previous fix only worked if the driver names did not match.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-30 12:19:03 -05:00
Yong Tang
c90ec05175 Restrict checkpoint name to prevent directory traversal
This fix tries to address the issue raised in 28769 where
checkpoint name was not checked before passing to containerd.
As a result, it was possible to use a special checkpoint name
to get outside of the container's directory.

This fix add restriction `[a-zA-Z0-9][a-zA-Z0-9_.-]+` (`RestrictedNamePattern`).
This is the same as container name restriction.

This fix fixes 28769.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-11-23 13:23:07 -08:00
zteBill
47b110a592 check err type
Signed-off-by: zteBill <bi.zhenkun@zte.com.cn>
2016-11-24 01:33:02 +08:00
Brian Goff
821aeb6a6f Use container Mounts API for Swarm containers.
Instead of converting nicely typed service mounts into untyped `Binds`
when creating containers, use the new `Mounts` API which is a 1-1
mapping between service mounts and container mounts.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-22 13:23:51 -05:00
Victor Vieux
9c559e6d0b fix a few golint errors
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2016-11-18 18:32:02 -08:00
Victor Vieux
9f348d5625 fix gofmt in master
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2016-11-18 15:20:19 -08:00
Brian Goff
22dccaf2d6 Merge pull request #28538 from yongtang/11162016-Log-Logf-fix
Fix several issues with `go vet` and `gofmt -s`
2016-11-17 15:21:22 -05:00
Yong Tang
ace786e9d5 Fix several issues with go vet and go fmt
For some reason, `go vet` and `go fmt` validate does not capture
several issues.

The following was the output of `go vet`:
```
ubuntu@ubuntu:~/docker$ go vet ./... 2>&1 | grep -v ^vendor | grep -v '^exit status 1$'
cli/command/formatter/container_test.go:393: possible formatting directive in Log call
volume/volume_test.go:257: arg mp.RW for printf verb %s of wrong type: bool
```

The following was the output of `go fmt -s`:
```
ubuntu@ubuntu:~/docker$ gofmt -s -l . | grep -v ^vendor
cli/command/stack/list.go
daemon/commit.go
```

Fixed above issues with `go vet` and `go fmt -s`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-11-17 06:31:28 -08:00
He Xin
19bd1cee23 fix bugs 'fatal error: concurrent map read and map write' to change VolumeStore.globalLock type from Mutex to RWMutex, and add globalLock.RLock() for the read of names, refs, labels and options in VolumeStore
Signed-off-by: He Xin <he_xinworld@126.com>
2016-11-17 10:48:19 +08:00
Victor Vieux
b06dc994f6 Merge pull request #27985 from muayyad-alsadi/17734-better-message-for-host-volumes
fixes #17734, clear message for host volumes not starting with /
2016-11-14 14:21:17 -08:00
Muayyad Alsadi
2d3df91436 remove "starting with /"
Signed-off-by: Muayyad Alsadi <alsadi@gmail.com>
2016-11-14 16:51:29 +02:00
Yanqiang Miao
19e2c9177a Fix a comment error
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-11-14 09:55:27 +08:00
Brian Goff
9a2d0bc3ad Fix uneccessary calls to volume.Unmount()
Fixes #22564

When an error occurs on mount, there should not be any call later to
unmount. This can throw off refcounting in the underlying driver
unexpectedly.

Consider these two cases:

```
$ docker run -v foo:/bar busybox true
```

```
$ docker run -v foo:/bar -w /foo busybox true
```

In the first case, if mounting `foo` fails, the volume driver will not
get a call to unmount (this is the incorrect behavior).

In the second case, the volume driver will not get a call to unmount
(correct behavior).

This occurs because in the first case, `/bar` does not exist in the
container, and as such there is no call to `volume.Mount()` during the
`create` phase. It will error out during the `start` phase.

In the second case `/bar` is created before dealing with the volume
because of the `-w`. Because of this, when the volume is being setup
docker will try to copy the image path contents in the volume, in which
case it will attempt to mount the volume and fail. This happens during
the `create` phase. This makes it so the container will not be created
(or at least fully created) and the user gets the error on `create`
instead of `start`. The error handling is different in these two phases.

Changed to only send `unmount` if the volume is mounted.

While investigating the cause of the reported issue I found some odd
behavior in unmount calls so I've cleaned those up a bit here as well.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-10 14:04:08 -05:00
Justin Cormack
5020905e9d Merge pull request #27329 from dattatrayakumbhar04/26639_nfs_volume_with_hostname
#26639: Local NFS volumes do not resolve hostnames
2016-11-09 13:46:56 +00:00
dattatrayakumbhar04
668fa8aff2 #26639: Local NFS volumes do not resolve hostnames
Signed-off-by: dattatrayakumbhar04 <dattatraya.kumbhar@gslab.com>
2016-11-08 08:26:53 +00:00
Akihiro Suda
3e3d3c8086 api: fix ReadOnly support for tmpfs
For `--mount type=tmpfs,target=/foo,readonly`, the `readonly` flag was just ignored.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-11-08 06:49:17 +00:00
Amit Krishnan
934328d8ea Add functional support for Docker sub commands on Solaris
Signed-off-by: Amit Krishnan <krish.amit@gmail.com>

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-11-07 09:06:34 -08:00
Anusha Ragunathan
cf55397e13 Merge pull request #27164 from cpuguy83/carry_24205
Fix volume creates blocked by stale cache entries
2016-11-03 10:28:13 -07:00