Commit Graph

2910 Commits

Author SHA1 Message Date
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
be189c5bc1 Merge pull request #20703 from riyazdf/notary-v0.2.0-vendor
Vendor in notary v0.2.0
Upstream-commit: e330d0749ce2d137249f290a4d20b0997279dbec
Component: engine
2016-02-26 08:53:07 -08:00
03ce1316a5 Merge pull request #20428 from jfrazelle/generate-conversion
generate seccomp profile convert type
Upstream-commit: c47674efda39226e7323e5668ee279927997fb4f
Component: engine
2016-02-26 10:28:23 -05:00
5bfa2d9a1f Merge pull request #20655 from hqhq/hq_fix_update_memoryswap
Fix problems when update swap memory
Upstream-commit: 6748cc10ac280950103d88a249f7d443715cf833
Component: engine
2016-02-25 22:28:53 -05:00
eadd157313 Merge pull request #20580 from BrianBland/crossRepoPushRetry
Improve auth fallback behavior for cross-repository push
Upstream-commit: d8b6e62f50c1ca40903b89a789b0a1806013a5b8
Component: engine
2016-02-25 16:37:04 -08:00
2bc21a41ec Merge pull request #20673 from Microsoft/jjh/testkill
Windows CI: Port TestKill*
Upstream-commit: 5cb4693300114436ac62697b0dff35c0f5bce9aa
Component: engine
2016-02-26 01:11:51 +01: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
aa1fcfa3ec Merge pull request #20697 from tiborvass/tls-remote-daemon-tests
Support TLS remote test daemon
Upstream-commit: 6fa5576e308d4c99e9a818f924483536a773afba
Component: engine
2016-02-25 16:16:40 -05: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
1f47465496 Fix TestExecApiStartWithDetach on WindowsTP4
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 21c85111231caeb6d2d342f13999d706cc33ff6a
Component: engine
2016-02-25 14:27:22 +01:00
5cbdc71804 Merge pull request #20679 from Microsoft/jjh/testrestart
Windows CI: Port docker_cli_restart_test.go
Upstream-commit: 7cf03700f891f0863f11ee57c2d3f8d68350d91b
Component: engine
2016-02-25 10:17:25 +01:00
6395a43374 Merge pull request #20677 from Microsoft/jjh/testclilogs
Windows CI: Port docker_cli_logs_test.go
Upstream-commit: ca7ce05e819959def59f8e3c07fdf03cbdcc0770
Component: engine
2016-02-25 09:38:23 +01:00
81c0ade270 Merge pull request #20682 from cpuguy83/fix_volplugin_panics
Fix panic when plugin responds with null volume
Upstream-commit: 0ad04242b4a7f98b691573f9095330ba9e74ae3b
Component: engine
2016-02-25 09:32:54 +01:00
bd2ade864c Merge pull request #20674 from Microsoft/jjh/testlogsapi
Windows CI: Port TestLogsAPI*
Upstream-commit: 9f1ad7850c03f75f9e69a8f3f76290533363ea7a
Component: engine
2016-02-25 09:11:15 +01:00
ca8a5e468f Merge pull request #20664 from Microsoft/jjh/busyboxtop
Windows CI: Integrity check for busybox top
Upstream-commit: abfc480f4be9a62c16e6af26160de8b80c805e51
Component: engine
2016-02-25 09:09:37 +01:00
b417dc79d3 Windows CI: Port docker_cli_logs_test.go
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 10bd587d77eff327cfb0dff2add4688a183c41a3
Component: engine
2016-02-24 20:19:48 -08:00
4d716f809c Merge pull request #20647 from coolljt0725/fix_20638
Fix exec start api with detach and AttachStdin at same time. fixes #2…
Upstream-commit: cee4ff1c4ac0bb47ed847f3bb725fd6233613937
Component: engine
2016-02-24 20:17:15 -08:00
acc7d09962 Improve fallback behavior for cross-repository push
Attempt layer mounts from up to 3 source repositories, possibly
falling back to a standard blob upload for cross repository pushes.
Addresses compatiblity issues with token servers which do not grant
multiple repository scopes, resulting in an authentication failure for
layer mounts, which would otherwise cause the push to terminate with an
error.

Signed-off-by: Brian Bland <brian.bland@docker.com>
Upstream-commit: 1d3480f9ba3525309030497d5c8a3dd5725ed15a
Component: engine
2016-02-24 19:13:35 -08:00
d1a3bc5db1 Fix exec start api with detach and AttachStdin at same time. fixes #20638
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: fb0ac1afd97e6e3bf3c13dcda5821f36b56cc62b
Component: engine
2016-02-24 21:04:44 -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
e682d2e8d7 Windows CI: Port docker_cli_restart_test.go
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 281c1ced6d6901ffb7faee209c243d0734abc792
Component: engine
2016-02-24 15:21:56 -08:00
dc55874ee6 Windows CI: Port TestLogsAPI*
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 00f65ae810679d587cb52466f52988ae9267e91d
Component: engine
2016-02-24 13:43:52 -08:00
d4cddca903 Windows CI: Port TestKill*
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 03e2ff322b064504f5c22bd5fbe863ae1c4bf0fc
Component: engine
2016-02-24 13:33:25 -08:00
4dd0ef305c Windows CI: Integrity check for busybox top
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 6a931c3590f5a2f274f9ab4c43452939d101a1b5
Component: engine
2016-02-24 11:00:47 -08:00
148812de36 Merge pull request #20637 from Microsoft/jjh/fixteststartattachmultiplecontainers
Windows CI: Fix TestStartAttachMultipleContainers
Upstream-commit: 467c8b1a6a866081081a90ea9cec94640638781a
Component: engine
2016-02-24 08:46:00 -08:00
8075c13623 Merge pull request #20619 from Microsoft/jjh/useraccounts
Windows: Updates for virtual user account
Upstream-commit: 5fdfb2985b209660a1a540222f614b73a0dc2e63
Component: engine
2016-02-24 13:48:27 +01:00
34876f5fef Merge pull request #20017 from calavera/expose_volumes_in_ps
Add mounts to docker ps.
Upstream-commit: 034a1a8dfd17d89123bf0405f898e880575ed775
Component: engine
2016-02-24 11:08:21 +01:00
1fba362e2f Restore container configs when update failed
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: fa3b1971578b3e270417df0215eeacaa03e881cf
Component: engine
2016-02-24 14:23:48 +08:00
da2ba30b2d Support update swap memory only
We should support update swap memory without memory.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: 8ae6f6ac28c1e9e28c1503b8118691580b66d885
Component: engine
2016-02-24 13:36:47 +08:00
ca915e8020 Windows CI: Fix TestStartAttachMultipleContainers
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: ef9f13af3d9293458a03223a030028381da4ae09
Component: engine
2016-02-23 16:24:35 -08:00
15f2e840f7 Fix flaky OOM tests
If cgroup swap memory limit isn't enabled, then
the -m flag doesn't work and the container that is created for
both of these tests is very large. Because we are trying to run the
containers out of memory, this takes a very long time and causes the
tests to fail most of the time.

Follow-up to #17913

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
Upstream-commit: 3abf2a77414195d5b0c15f7fc88b7fd9aa4edaa8
Component: engine
2016-02-23 15:26:26 -05:00
c1d2fd21f7 Fix flaky TestExec
The container started with `-d` as part of the test requires a `waitRun`
to ensure it is actually running before attempting any other operation.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Upstream-commit: 0a7755ab4e2fc8df1992813d5364fe0f201ab913
Component: engine
2016-02-23 09:51:09 -08: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
edf220176a Add mounts to docker ps.
- Allow to filter containers by volume with `--filter volume=name` and `filter volume=/dest`.
- Show their names in the list with the custom format `{{ .Mounts }}`.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: bd4fb00fb6241d35537b460a2d9f48256111ae7a
Component: engine
2016-02-23 12:10:24 -05:00
39d894b6e8 Merge pull request #20581 from stweil/master
Fix some typos in comments and strings
Upstream-commit: 9d882cbb442138cb5c9026f1ec8eb4499ad71442
Component: engine
2016-02-23 08:20:53 -08:00
f04054d6f5 Fix typo
Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
Upstream-commit: 8474bbff4594f382dbac5ad59767d18b2d8f2689
Component: engine
2016-02-23 17:27:55 +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
dce4ee668d Unskip authz events test after fixes
Now that the various fixes are all committed, let's see if this gets
less flaky now.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Upstream-commit: 4781d5c4fb06d4617189f2e8a9475abcc5c5c8f3
Component: engine
2016-02-20 20:19:54 -06:00
4ea7e9ea28 Merge pull request #20509 from estesp/cleanup-authz-test
Clean up authz integration-cli test
Upstream-commit: 076b3558fcf4cc77694fe53f4aae65137ed3ef1b
Component: engine
2016-02-20 12:10:29 +01:00
f153cf13ed Update RestartPolicy of container
Add `--restart` flag for `update` command, so we can change restart
policy for a container no matter it's running or stopped.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: ff3ea4c90f2ede5cccc6b49c4d2aad7201c91a4c
Component: engine
2016-02-20 17:06:32 +08:00
2d2a092a9b Merge pull request #20446 from estesp/fix-userns-cp
Fix copy chown settings to not default to real root
Upstream-commit: 3d65e7126c60ef23a7f0e255cd2e4b5938859413
Component: engine
2016-02-19 19:45:44 -05:00
f30528fead Allow post-start load of busybox to remove restarts
The restarts in the authz plugin test suite seems to be causing
flakiness in CI, and can be avoided by separating the daemon start and
busybox image load.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Upstream-commit: fe015c5ce0a260a8b5bc346a297507ac91f0ccb4
Component: engine
2016-02-19 18:44:36 -06:00
f92b8a2bd5 Merge pull request #20464 from cpuguy83/fix_events_flakiness
Fix events test flakiness.
Upstream-commit: b9195cd6d416280a021eaa630bd333453f71e270
Component: engine
2016-02-19 15:39:27 -08:00
4b3e3eb7e6 add seccomp default profile fix tests
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 11435b674b8ed580f8cf401c7cee7d24f59d7a43
Component: engine
2016-02-19 13:32:54 -08:00
34184bd076 Merge pull request #20383 from HackToday/addsort
Make network ls output order
Upstream-commit: 0e72550c5b27704ac1ec043302fe2aaebe3b1956
Component: engine
2016-02-19 15:42:48 -05:00
033a056f03 Merge pull request #20389 from HackToday/addvolumesupport
Make volume ls output order
Upstream-commit: 48701888c216868379ee430e041f7a9568970117
Component: engine
2016-02-19 15:41:34 -05:00
58b5075165 Temporarily skip TestAuthZPluginAllowEventStream
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Upstream-commit: 6e0f873f053f5ae54901177cd5272f6fef7d49a0
Component: engine
2016-02-19 10:32:05 -08:00
e0d79dff72 Clean up authz integration-cli test
- Order the flow of the handlers more cleanly--read req, do actions,
  write response.
- Add "always allowed" endpoints to handle `/_ping` and `/info` usage
  from the test framework/daemon start/restart management

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
Upstream-commit: 074561b0ecc1e1b2e476c5aa06a8e6ea858239c1
Component: engine
2016-02-19 10:12:39 -08:00
d9c028ed66 Merge pull request #20419 from aboch/cr
Allow passing global datastore to libnetwork and v0.7.0-dev1 vendoring
Upstream-commit: 117a982d2e805d3279ff75fcec071635e5191ef6
Component: engine
2016-02-18 17:39:46 -08:00