Commit Graph

33961 Commits

Author SHA1 Message Date
bc89af9929 Simplify/fix MkdirAll usage
This subtle bug keeps lurking in because error checking for `Mkdir()`
and `MkdirAll()` is slightly different wrt to `EEXIST`/`IsExist`:

 - for `Mkdir()`, `IsExist` error should (usually) be ignored
   (unless you want to make sure directory was not there before)
   as it means "the destination directory was already there"

 - for `MkdirAll()`, `IsExist` error should NEVER be ignored.

Mostly, this commit just removes ignoring the IsExist error, as it
should not be ignored.

Also, there are a couple of cases then IsExist is handled as
"directory already exist" which is wrong. As a result, some code
that never worked as intended is now removed.

NOTE that `idtools.MkdirAndChown()` behaves like `os.MkdirAll()`
rather than `os.Mkdir()` -- so its description is amended accordingly,
and its usage is handled as such (i.e. IsExist error is not ignored).

For more details, a quote from my runc commit 6f82d4b (July 2015):

    TL;DR: check for IsExist(err) after a failed MkdirAll() is both
    redundant and wrong -- so two reasons to remove it.

    Quoting MkdirAll documentation:

    > MkdirAll creates a directory named path, along with any necessary
    > parents, and returns nil, or else returns an error. If path
    > is already a directory, MkdirAll does nothing and returns nil.

    This means two things:

    1. If a directory to be created already exists, no error is
    returned.

    2. If the error returned is IsExist (EEXIST), it means there exists
    a non-directory with the same name as MkdirAll need to use for
    directory. Example: we want to MkdirAll("a/b"), but file "a"
    (or "a/b") already exists, so MkdirAll fails.

    The above is a theory, based on quoted documentation and my UNIX
    knowledge.

    3. In practice, though, current MkdirAll implementation [1] returns
    ENOTDIR in most of cases described in #2, with the exception when
    there is a race between MkdirAll and someone else creating the
    last component of MkdirAll argument as a file. In this very case
    MkdirAll() will indeed return EEXIST.

    Because of #1, IsExist check after MkdirAll is not needed.

    Because of #2 and #3, ignoring IsExist error is just plain wrong,
    as directory we require is not created. It's cleaner to report
    the error now.

    Note this error is all over the tree, I guess due to copy-paste,
    or trying to follow the same usage pattern as for Mkdir(),
    or some not quite correct examples on the Internet.

    [1] https://github.com/golang/go/blob/f9ed2f75/src/os/path.go

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 516010e92d56cfcd6d1e343bdc02b6f04bc43039
Component: engine
2017-11-27 17:32:12 -08:00
03d850d672 idtools.MkdirAs*: error out if dir exists as file
Standard golang's `os.MkdirAll()` function returns "not a directory" error
in case a directory to be created already exists but is not a directory
(e.g. a file). Our own `idtools.MkdirAs*()` functions do not replicate
the behavior.

This is a bug since all `Mkdir()`-like functions are expected to ensure
the required directory exists and is indeed a directory, and return an
error otherwise.

As the code is using our in-house `system.Stat()` call returning a type
which is incompatible with that of golang's `os.Stat()`, I had to amend
the `system` package with `IsDir()`.

A test case is also provided.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 2aa13f86f0c9cf3ed58a648a7b1506d4b06f3589
Component: engine
2017-11-27 13:25:44 -08:00
5c33ebfbc1 Merge pull request #33892 from thaJeztah/bump-golang-19
Bump Go to 1.9.2
Upstream-commit: c672fbd69cb2b375011867860b3f46220655d3fe
Component: engine
2017-11-27 11:44:06 -08:00
9a7fb33c58 Merge pull request #35579 from dnephin/fix-layer-dne
Fix layer DNE with duplicate layers
Upstream-commit: 9fe48f081dafbff467643ce1119c7963f57d9ee8
Component: engine
2017-11-27 09:40:54 -08:00
c7f0d04c5e Merge pull request #33731 from runcom/rt-fix-update
container: update real-time resources
Upstream-commit: dfe2c023a34de3e1731e789f4344ef4d85070bc6
Component: engine
2017-11-23 18:30:22 -08:00
b02966efb1 Merge pull request #35563 from soccerGB/driveroptionpersist
Added support for persisting Windows network driver specific options …
Upstream-commit: 1f3f111b4577b29613b0ffef8f001679c2a62d6f
Component: engine
2017-11-23 16:31:46 -08:00
a737bf6704 Fix layer DNE with duplicate layers.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 936ef0c4c97737066ae1e028f04b5188022a91b8
Component: engine
2017-11-23 15:41:59 -05:00
dd75028635 Merge pull request #35576 from tophj-ibm/add-main-to-image-tests
[integration] add main_test for image test
Upstream-commit: fe8aac6f5ae413a967adb0adad0b54abdfb825c4
Component: engine
2017-11-22 14:42:56 -08:00
b88ff8a5c2 container: update real-time resources
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: dca82b9e5c53e96d1e34bec03e78e17feb8d6fdb
Component: engine
2017-11-22 22:21:40 +01:00
9f84ce63a5 [integration] add main_test for image test
Adds a main_test for the image integration test, so we can download
frozen images, and clean up after the image test is ran

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
Upstream-commit: be83f42612e3be42fcd60726d48d7346befc9449
Component: engine
2017-11-22 11:13:32 -05:00
26b47c13d1 Merge pull request #35467 from kolyshkin/dup-mnt
Fix "duplicate mount point" when --tmpfs /dev/shm is used
Upstream-commit: d032264e1365a1cea621b7105e1ca521cb4218ef
Component: engine
2017-11-22 12:13:06 +01:00
4a5f32be3b Merge pull request #35541 from thaJeztah/remove-deprecated-mkdirallas
Remove uses of deprecated MkdirAllAs(), MkdirAs()
Upstream-commit: 84b1f813a4ada3c19eea84f9e98c56c0768d9da2
Component: engine
2017-11-22 17:49:37 +09:00
e6fc3af770 Added support for persisting Windows network driver specific options over reboot or service restart
Signed-off-by: Cheng-mean Liu <soccerl@microsoft.com>
Upstream-commit: cef1578ac46e02d05c86621505631b3be7ca9d72
Component: engine
2017-11-21 14:11:12 -08:00
86481c358f Merge pull request #35559 from thaJeztah/remove-testutil
Remove unused "testutil" package
Upstream-commit: ce452fb72ffcdb7605ce98bde9302238f47c63c5
Component: engine
2017-11-21 21:00:04 +01:00
605885e518 Bump Go to 1.9.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: d6e1cc32d309ee237342975388e729570343a974
Component: engine
2017-11-21 20:57:02 +01:00
7ed4a89d21 Merge pull request #35554 from darrenstahlmsft/RevendorHcsshim
Update hcsshim to v0.6.7 for go1.9 support
Upstream-commit: fb89afb6898fc830b8f660931f54145f85b971c7
Component: engine
2017-11-21 20:55:40 +01:00
6063e62a1f Remove unused "testutil" package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 47af9f625d3f9e94729ec5aee4abcce813914d07
Component: engine
2017-11-21 15:09:23 +01:00
d0d7235731 Remove deprecated MkdirAllAs(), MkdirAs()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 38b3af567f676c4c35e80e493aa97b7346ae75e4
Component: engine
2017-11-21 13:53:54 +01:00
9282ca8404 Minor refactor in idtools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ce66470f5404872db2cbaa7fbd59970700144be2
Component: engine
2017-11-21 13:49:58 +01:00
d4007aa747 Update idtools tests to test non-deprecated functions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 9aba019b72611119578ea32adb03fa49f73da522
Component: engine
2017-11-21 13:47:17 +01:00
c051f4a135 Merge pull request #35547 from thaJeztah/fix-make-test
Fix "make test" failing on missing "test-unit"
Upstream-commit: dc7ba2ca3ba7abd1aa4dbbcb3c42dace1b6d3545
Component: engine
2017-11-21 10:49:38 +01:00
6e7cb1931d Fix "duplicate mount point" when --tmpfs /dev/shm is used
This is a fix to the following issue:

$ docker run --tmpfs /dev/shm busybox sh
docker: Error response from daemon: linux mounts: Duplicate mount point '/dev/shm'.

In current code (daemon.createSpec()), tmpfs mount from --tmpfs is added
to list of mounts (`ms`), when the mount from IpcMounts() is added.
While IpcMounts() is checking for existing mounts first, it does that
by using container.HasMountFor() function which only checks container.Mounts
but not container.Tmpfs.

Ultimately, the solution is to get rid of container.Tmpfs (moving its
data to container.Mounts). Current workaround is to add checking
of container.Tmpfs into container.HasMountFor().

A unit test case is included.

Unfortunately we can't call daemon.createSpec() from a unit test,
as the code relies a lot on various daemon structures to be initialized
properly, and it is hard to achieve. Therefore, we minimally mimick
the code flow of daemon.createSpec() -- barely enough to reproduce
the issue.

https://github.com/moby/moby/issues/35455

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 1861abdc4a31efad202a5c3d89a895bb7a62799a
Component: engine
2017-11-20 18:48:27 -08:00
69bca6d97b container.NetworkMounts(): don't lookup mounts twice
The code in question looks up mounts two times: first by using
HasMountFor(), and then directly by looking in container.MountPoints.
There is no need to do it twice.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: eab3ac3e70a510b97f9399efd13e3dc01a07c413
Component: engine
2017-11-20 18:48:27 -08:00
63aefcb844 Update hcsshim to v0.6.7 for go1.9 support
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 0bee8049c78c635b8a38064483e4c3c788779345
Component: engine
2017-11-20 16:29:01 -08:00
3cf67e0ba5 Merge pull request #35517 from stevvooe/protect-the-health-status
container: protect the health status with mutex
Upstream-commit: 9de84a78d76ed2ffe386fe21466f7401cf5d2e9d
Component: engine
2017-11-20 21:51:47 +01:00
325141c0ef Merge pull request #35495 from simonferquel/isolation-validation
Added validation of isolation settings on daemon.verifyContainerSettings
Upstream-commit: a9aeb18a0996eed4b3402ba0431269d46f5ad497
Component: engine
2017-11-20 12:09:40 -08:00
276378cfb9 Fix "make test" failing on missing "test-unit"
Commit dbf580be57a4bb854d7ce20d313e3a22ea337be5 removed
this helper script because it's no longer used in CI.

However, the "make test" target in the Makefile still
called this helper, resulting it to fail.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a17071e88f15625a6be19f80c697ab1c3471381b
Component: engine
2017-11-20 19:12:25 +01:00
454988ca17 Merge pull request #35542 from masaeedu/patch-1
Fix consumes MIME type for NetworkConnect
Upstream-commit: 4f4a0279084921756d2b2157ad272610d7adc0ae
Component: engine
2017-11-20 18:13:26 +01:00
38076c34e8 Added validation of isolation settings on daemon.verifyContainerSettings
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
Upstream-commit: e6bfe9cdcb32e97f38b53781eb1f9d7bd2ef5971
Component: engine
2017-11-20 10:34:20 +01:00
be9497fbf4 Fix consumes MIME type for NetworkConnect
This route expects `application/json`. Sending a content type header of `application/octet-stream` results in an error.

Signed-off-by: Asad Saeeduddin <masaeedu@gmail.com>
Upstream-commit: 876b32861789a0424557c640622bde47eedd2d98
Component: engine
2017-11-18 22:34:23 -05:00
23f0e9211c Merge pull request #35522 from kolyshkin/gd-custom
graphdriver: custom build-time priority list
Upstream-commit: edc204b1ffd53252649917fe54daa0b8419ed4ec
Component: engine
2017-11-17 15:48:26 -08:00
e533bd8d7a Merge pull request #35526 from brauner/2017-11-16/docker_xfs_quota_userns
skip xfs quota tests when running in user namespace
Upstream-commit: 8124d21d2ad7666e73551fcc317c109c6a02e122
Component: engine
2017-11-17 13:41:58 -05:00
94aae8ab65 Skip further checks for quota in user namespaces
Commit 7a1618ced359a3ac921d8a05903d62f544ff17d0 regresses running Docker
in user namespaces. The new check for whether quota are supported calls
NewControl() which in turn calls makeBackingFsDev() which tries to
mknod(). Skip quota tests when we detect that we are running in a user
namespace and return ErrQuotaNotSupported to the caller. This just
restores the status quo.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Upstream-commit: 7e35df0e0484118740dbf01e7db9b482a1827ef1
Component: engine
2017-11-17 12:57:27 +01:00
0db60dff81 graphdriver: custom build-time priority list
Add a way to specify a custom graphdriver priority list
during build. This can be done with something like

  go build -ldflags "-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper"

As ldflags are already used by the engine build process, and it seems
that only one (last) `-ldflags` argument is taken into account by go,
an envoronment variable `DOCKER_LDFLAGS` is introduced in order to
be able to append some text to `-ldflags`. With this in place,
using the feature becomes

  make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary

The idea behind this is, the priority list might be different
for different distros, so vendors are now able to change it
without patching the source code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 17708e72a7ef29fb1d4b03fbded1c5e4c08105fd
Component: engine
2017-11-16 19:43:34 -08:00
a1c54edb95 container: protect the health status with mutex
Adds a mutex to protect the status, as well. When running the race
detector with the unit test, we can see that the Status field is written
without holding this lock. Adding a mutex to read and set status
addresses the issue.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: 7db30ab0cdf072956d2ceda833b7de22fe17655c
Component: engine
2017-11-16 15:04:01 -08:00
42bb16a0de Merge pull request #35512 from cpuguy83/replace_plugun_integration_with_unit
Replace vol plugin integration test w/ unit test
Upstream-commit: ab90bc296155f341f8315a265b3c6d8112512db2
Component: engine
2017-11-16 17:35:23 +01:00
9ef2726179 Replace vol plugin integration test w/ unit test
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 00d801dd85b486eb46eff7bd041c33f04e373699
Component: engine
2017-11-15 13:13:22 -05:00
8771152e42 Merge pull request #35429 from dnephin/build-fails-on-long-label
Fix dockerfile parser failing silently on long tokens
Upstream-commit: 7c53e732530642f817c83e1ad303f8f9f7018def
Component: engine
2017-11-15 18:48:50 +01:00
cffc0c967c Merge pull request #35492 from thaJeztah/bump-docker-py
Bump docker-py to 1d6b5b203222ba5df7dedfcd1ee061a452f99c8a
Upstream-commit: a5c679baf66488e89ccf93c2282b96673acbcb0e
Component: engine
2017-11-15 07:31:14 -08:00
55c5f024c9 Merge pull request #35504 from kolyshkin/sep-o2
daemon/graphdriver/register: separate overlay2
Upstream-commit: fa1054843f9a8a32ca33be6b73167069a8344ecf
Component: engine
2017-11-15 09:21:08 -05:00
3647d18f55 Merge pull request #35499 from cpuguy83/erroneous_errors
Cancelation errors should not be logged
Upstream-commit: 7c16e4d41769bcedfd987507ac150f516358a120
Component: engine
2017-11-15 11:34:28 +01:00
ce594a83b1 daemon/graphdriver/register: separate overlay2
Make it possible to disable overlay and overlay2 separately.

With this commit, we now have `exclude_graphdriver_overlay` and
`exclude_graphdriver_overlay2` build tags for the engine, which
is in line with any other graph driver.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: d014be5426c869d429c1a11cad9e76321dd7a326
Component: engine
2017-11-15 00:06:00 -08:00
ae3d074947 Cancelation errors should not be logged
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b86746d60d4c43dcadd3b95fc4b2da7c03323d84
Component: engine
2017-11-14 20:32:20 -05:00
005014677c Merge pull request #34896 from cpuguy83/store_labels_when_exists
Create labels when volume exists only remotely
Upstream-commit: f62aeae97791b4c2318791a9b621d7da4c17ac32
Component: engine
2017-11-14 17:05:40 -08:00
6ad432f442 Merge pull request #35482 from stevvooe/protect-health-monitor-channel
container: protect health monitor channel
Upstream-commit: e4d0fe84f9ea88b0e0cfd847412c9f29442cc62d
Component: engine
2017-11-14 11:25:14 -08:00
4bd3446b2b Merge pull request #35231 from sargun/add-vfs-quota-support
Add vfs quota support
Upstream-commit: 0defc6981322e16863e068f99b98326394b8cbd0
Component: engine
2017-11-14 15:05:02 +00:00
d8cda430a7 Bump docker-py to 1d6b5b203222ba5df7dedfcd1ee061a452f99c8a
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: d1a0773d3a834a4bfa98deb07ae3f87dd6438da6
Component: engine
2017-11-14 14:17:44 +01:00
15db98f6fa Merge pull request #35465 from cpuguy83/update_containerd
Update containerd to v1 beta3
Upstream-commit: b4fbcd80c796f384eba800d1dc89892ab77c58e5
Component: engine
2017-11-14 14:01:48 +01:00
2cc0ade7cc Merge pull request #35484 from tonistiigi/clear-state
libcontainerd: fix leaking container/exec state
Upstream-commit: 1c99bc481be6abf40d4fd287d1b6634a6108a211
Component: engine
2017-11-14 11:15:30 +01:00
6f6f835501 Merge pull request #35316 from kolyshkin/facepalm
Fix honoring tmpfs-size for user /dev/shm mount
Upstream-commit: f70c715be01f5d5f4a8be4ab1b2c6e1464b478a7
Component: engine
2017-11-14 11:13:59 +01:00