Commit Graph

511 Commits

Author SHA1 Message Date
547c60d84c More descriptive error when running a container with a too long hostname (#21445)
This fix tries to fix issues encountered when running a container with a hostname
that is longer than HOST_NAME_MAX(64).

Previously, `could not synchronise with container process` was generated as the
length of the regex check was missing.

This fix covers the length check so that a hostname that is longer than
HOST_NAME_MAX(64) will be given a correct error message.

Several unit tests cases and additional integration test cases are added as well.

This fix closes #21445.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: fa44b4e81ee87f1c2b39ad335a22795415c8cdf2
Component: engine
2016-03-24 17:42:28 +00:00
dba13cd8af Re-enable shared namespace tests for userns CI runs
Allow --net=container and --ipc=container tests to run when user
namespaces are enabled.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Upstream-commit: a1d84411178bdf72be83ad292543a1ea70aa3f69
Component: engine
2016-03-23 09:39:24 -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
cd3a202f52 Fix one-character directory issue in the volume option (#20122).
The issue comes from the implementation of volumeSplitN() where a
driver letter (`[a-zA-Z]:`) was assumed to follow either `:`, `/`,
or `\\`.

In Windows driver letter appears in two situations:
a. `^[a-zA-Z]:` (A colon followed  by `^[a-zA-Z]:` is OK as colon is
the separator in volume option)
b. A string in the format like `\\?\C:\Windows\...` (UNC).
Therefore, a driver letter can only follow either a `:` or `\\`

This PR removes the condition of `/` before the driver letter so
that options like `-v /tmp/q:/foo` could be handled correctly. A
couple of tests has also been added.

This PR fixes #20122.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 800a7d513d3b80478a7996cb2c357b72f65e0b09
Component: engine
2016-03-21 02:55:06 +00:00
ba41c51be4 Merge pull request #20662 from tonistiigi/containerd-integration
Containerd integration
Upstream-commit: e5a3f86e447dd659da3c2e759f3c088a0bfcfe3d
Component: engine
2016-03-18 17:21:18 -07:00
8ba16d91c8 Replace execdrivers with containerd implementation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 9c4570a958df42d1ad19364b1a8da55b891d850a
Component: engine
2016-03-18 13:38:32 -07:00
cb854bf11c Consolidate security options to use = as separator.
All other options we have use `=` as separator, labels,
log configurations, graph configurations and so on.
We should be consistent and use `=` for the security
options too.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: cb9aeb0413ca75bb3af7fa723a1f2e6b2bdbcb0e
Component: engine
2016-03-17 13:34:42 -04:00
04c0a38220 Fix flaky test TestRunAttachFailedNoLeak in #21247.
The issue of the flaky test is because when the second container
starts, the first container in the detached mode may have only
been created and not yet entering the running state. So the
port 8000 might be used by the second container first.

This fix added a check to make sure the first container is already
in running state, before the second container is invoked.

This fix fixes #21247.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 1a9f5f4c69451c580595d67844f41937b3293069
Component: engine
2016-03-17 03:14:59 +00:00
6b75bb519f Merge pull request #20177 from jheiss/12076-net_hostname
Allow --hostname with --net=host
Upstream-commit: 21e531014db65422e1a3000fd3596459f55870c4
Component: engine
2016-03-15 08:17:25 -07:00
2f4ce11dc1 Merge pull request #21196 from LK4D4/detect_leaks_util
integration-cli: move goroutines info helpers to separate funcs
Upstream-commit: daabb45d0ac6c332ef0b54c30f70dfa2b459d362
Component: engine
2016-03-15 12:42:47 +01:00
1f830d0241 integration-cli: move goroutines info helpers to separate funcs
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 0c7c9df8048353f3ff84d88d4311196546ba56cf
Component: engine
2016-03-14 15:52:56 -07:00
b59f91dbea Merge pull request #21151 from mountkin/optimize-test
optimize slow tests
Upstream-commit: 01f165169b6913320defdc9ce3995614e4c286d1
Component: engine
2016-03-14 16:39:01 -04:00
1ddccf6e06 Merge pull request #21048 from LK4D4/fix_attach_leak
daemon: fix hanging attaches on initial start failures
Upstream-commit: 8e74cf59d06ce0052193ec8216db5dca7eec4981
Component: engine
2016-03-14 10:16:45 -07:00
080e34c27c speed up DockerSuite.TestRunContainerWithReadonlyRootfs
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Upstream-commit: fc284a856947538d3cc086e53740b2b782df53b9
Component: engine
2016-03-12 18:58:03 +08:00
b4a4774b91 daemon: fix hanging attaches on initial start failures
Attach can hang forever if there is no data to send. This PR adds notification
of Attach goroutine about container stop.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 7bb815e2960c97c5cc0624566ac51581bdd884ab
Component: engine
2016-03-10 07:38:46 -08:00
76a4963d49 Allow --hostname with --net=host
Docker creates a UTS namespace by default, even with --net=host, so it
is reasonable to let the user set the hostname. Note that --hostname is
forbidden if the user specifies --uts=host.

Closes #12076
Signed-off-by: Jason Heiss <jheiss@aput.net>
Upstream-commit: 3f445e63b4568845f439c5d30a99ba10603b1938
Component: engine
2016-03-09 20:40:12 -05:00
eb5f497921 Merge pull request #20965 from yongtang/19425-DockerSuite.TestRunUnshareProc
Optimize slow bottleneck test of DockerSuite.TestRunUnshareProc.
Upstream-commit: 5d3ae7f98999e3f01125c5dd9ac73757dbb849ef
Component: engine
2016-03-09 10:32:09 -05:00
98685a6505 Ensure WORKDIR is created with remapped root ownership
Correct creation of a non-existing WORKDIR during docker build to use
remapped root uid/gid on mkdir

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Upstream-commit: 799a6b94ee661022d66f88a009ff58f08eb5a2c3
Component: engine
2016-03-08 11:58:55 -05:00
727ed3e381 Optimize slow bottleneck test of DockerSuite.TestRunUnshareProc.
This fix tries to improve the time to run TestRunUnshareProc
in #19425.
In this fix goroutines are used to run test cases in parallel to
prevent the test from taking a long time to run.
As the majority of the execution time in the tests is from
multiple executions of 'docker run' and each of which takes
several seconds, parallel executions improve the test time.
Since each 'docker run' is independent, the purpose of the
test is not altered in this fix.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 526c2fe942107908fe324db2ecceee14b69cb191
Component: engine
2016-03-07 23:43:16 +00:00
a2c76ae251 Add tests of unsupported network-scoped alias on default networks
Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
Upstream-commit: 0515d9b9c0cbfa9d10b98c58f428f599174e961e
Component: engine
2016-03-02 16:57:50 +08:00
f444846f4e integration-cli: remove not necessary -d again
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: e44689139d2ffd08c147ffe940a15a8e8616786a
Component: engine
2016-02-28 13:48:15 +01:00
8135f8d68c Merge pull request #20699 from calavera/remove_static_error_declarations
Remove static errors from errors package.
Upstream-commit: df2b74188ec51422e84ec1dbdc58abf08c215019
Component: engine
2016-02-26 16:30:12 -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
534b2f0779 Vendor in notary v0.2.0
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
Upstream-commit: 84dc2d9e70f1ad4422732421e2d6b91274f4dfae
Component: engine
2016-02-25 13:40:00 -08:00
cfd2e7e48d Support TLS remote test daemon
This will allow us to have a windows-to-linux CI, where the linux host
can be anywhere, connecting with TLS.

Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: f4a1e3db998816e5fcb0df56c29519c488890464
Component: engine
2016-02-25 14:12:17 -05:00
e1a3cdb877 Windows: Updates for virtual user account
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 800c9e81ea9093d587c18bc5c1fd7c0a73b1293f
Component: engine
2016-02-23 09:47:52 -08:00
f62b97e499 Fix some typos in comments and strings
Most of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Upstream-commit: 2eee613326fb59fd168849618d14a9054a40f9f5
Component: engine
2016-02-22 20:27:15 +01:00
bc74abda34 runconfig: opts: parse: lowercase errors
also fix wrong function comment

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: d266142230bd041c8299eef329cf79a17f8f7478
Component: engine
2016-02-18 11:21:44 +01: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
6d4102dcb8 Merge pull request #20133 from mlaventure/dont-bind-mount-mqueue
Prevent mqueue from implicitely becoming a bind mount with --ipc=host
Upstream-commit: 0b4a7fb06d4b77265831cee1508aad9fbeddb7a2
Component: engine
2016-02-09 19:55:57 -05:00
7d8fc9149c Merge pull request #19985 from Microsoft/CombineSetupWorkingDir
Combine SetupWorkingDirectory for Linux and Windows
Upstream-commit: d6870238e329e43d2df291a5f82d27929f9a192d
Component: engine
2016-02-09 15:18:49 -08:00
a7fd8e1725 Disable TestRunMountshmmqueuefromhost when using userns
Since we now automatically mount the mqueue device inside the
container (instead of bind mounting the one from the host), when
trying to start a container with --ipc=host, the mount will fail with
EPERM.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: dba5a7f243e6c251176585571419b595172e9402
Component: engine
2016-02-09 14:16:08 -08:00
24558a48dd Prevent mqueue from implicitely becoming a bind mount with --ipc=host
Currently, when running a container with --ipc=host, if /dev/mqueue is
a standard directory on the hos the daemon will bind mount it allowing
the container to create/modify files on the host.

This commit forces /dev/mqueue to always be of type mqueue except when
the user explicitely requested something to be bind mounted to
/dev/mqueue.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: f7d4abdc00d521509995da1070215c808fe0fd9c
Component: engine
2016-02-09 14:16:08 -08:00
2fc41c0b8b Combine SetupWorkingDirectory for Linux and Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 6791230320fa9f8ae9df3e90d5c52d85621828a0
Component: engine
2016-02-05 10:27:10 -08:00
1262ec37e1 Windows CI: Up timeout TestRunRestartMaxRetries
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 4a2122e020f2f4637b2a32e1ba2bfa3511988f8f
Component: engine
2016-02-04 11:59:13 -08:00
3e36908d7b Add a getPrefixAndSlashFromDaemonPlatform …
… to limit code duplication in integration tests :P

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 382c96ee7b02f393e7515e4cc4882738398b86a6
Component: engine
2016-02-03 15:16:00 +01:00
9de80c7080 Fix windows CI test
The windows CI is not clean in some tests, this try address that.

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
Upstream-commit: 7ed10d4a4cc724fe6ce3f623051546710a18a3b6
Component: engine
2016-02-02 04:54:14 +00:00
342ab710cd Signed-off-by: John Howard <jhoward@microsoft.com>
Revert "Combine SetupWorkingDirectory for Linux and Windows"

This reverts commit ec31741ca186278ea60faf49f85087c493e78806.
Upstream-commit: 54320d8d187d8b33be4fd33cfb3f8e486c6c8d90
Component: engine
2016-01-29 20:49:39 -08:00
2b701e53fd Merge pull request #19815 from Microsoft/jjh/testruncreatevolumesinsymlinkdir
Fix TestRunCreateVolumesInSymlinkDir
Upstream-commit: 9c3cca23e9d8ba62fac2ee29887cf029e42f661b
Component: engine
2016-01-29 21:07:51 -05:00
9d6400f4f2 Merge pull request #19805 from WeiZhang555/test-inspect
Make test code consistent
Upstream-commit: 35ef3efe9af64c22c7efbe826f8f63b025639130
Component: engine
2016-01-29 12:43:58 -08:00
c11bcbefde Fix TestRunCreateVolumesInSymlinkDir
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 90b0292b5b06c5e71d47e5dee34d3d4744682506
Component: engine
2016-01-29 09:28:48 -08:00
8bc92ae008 Assert error in body of function inspectField*
1. Replace raw `docker inspect -f xxx` with `inspectField`, to make code
cleaner and more consistent
2. assert the error in function `inspectField*` so we don't need to
assert the return value of it every time, this will make inspect easier.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: 62a856e9129c9d5cf7db9ea6322c9073d68e3ea4
Component: engine
2016-01-29 23:39:07 +08:00
88afeb1908 Combine SetupWorkingDirectory for Linux and Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: ec31741ca186278ea60faf49f85087c493e78806
Component: engine
2016-01-27 16:17:35 -08:00
142063ee1c Update integration tests with new error messages, and to use different repos per test.
This way we won't encounter any problems with one test using cached data from a different
test.

Signed-off-by: cyli <cyli@twistedmatrix.com>
Upstream-commit: 0617521ba2ce160899852bb707c15bae7309f18a
Component: engine
2016-01-26 18:02:00 -08: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
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
48b99fc11d Make test case name consistent
Replace `Tty` with `TTY` in all test case names so that we can run
a bundle of `TTY` related test cases with TESTFLAGS like
`-check.f TestExecTTY*`

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: e151ad936abecce944e3f7c285fa788c2dc1bba1
Component: engine
2016-01-24 16:32:52 +08:00
43d94b4fad Windows CI: Fix TestRunExitOnStdinClose
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 4bfc5d4606da8ed04fbba850da1c9b9e0d1ba3fe
Component: engine
2016-01-22 18:27:15 -08:00
dd594705a0 Merge pull request #19579 from cyphar/hotfix-vendor-libcontainer
Hotfix vendor libcontainer
Upstream-commit: 6d1455e74b388faeae0f90379b8aa908afed0bf7
Component: engine
2016-01-22 16:46:04 -08:00
b0e4ddb0d5 integration-cli: add bad --cgroup-parent tests
To ensure we don't regress on bad --cgroup-parent paths, add some
integration tests that check that the host hasn't toppled (or suddently
started to create files in the host).

Signed-off-by: Aleksa Sarai <asarai@suse.com>
Upstream-commit: cc19c7df2acd02d7580c726b11f50e85f253ace8
Component: engine
2016-01-22 20:16:56 +11:00