Commit Graph

683 Commits

Author SHA1 Message Date
697f71e4f2 Add support for reading logs extra attrs
The jsonlog logger currently allows specifying envs and labels that
should be propagated to the log message, however there has been no way
to read that back.

This adds a new API option to enable inserting these attrs back to the
log reader.

With timestamps, this looks like so:
```
92016-04-08T15:28:09.835913720Z foo=bar,hello=world hello
```

The extra attrs are comma separated before the log message but after
timestamps.

Without timestaps it looks like so:
```
foo=bar,hello=world hello
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: bd9d14a07b9f1c82625dc8483245caf3fa7fe9e6
Component: engine
2016-05-06 20:42:20 -04:00
1f29278b9e Fix bug: exec non-exist command miss a "\n"
When exec a non-exist command, it should print a newline at last.

Currently:
```
$ docker exec -ti f5f703ea2c0a144 bash
rpc error: code = 2 desc = "oci runtime error: exec failed: exec:
\"bash\": executable file not found in $PATH"$
```

Signed-off-by: Feng Yan <fy2462@gmail.com>
Upstream-commit: 8bf5613c1aca634e517e895e90e74f4263cf030f
Component: engine
2016-04-28 16:39:00 +08:00
b1397d2034 api: server: check for unauthorized error
This functionality has been fixed by
7bca93218291767c5dd8782de0ad630dbcda9995 but then it has been broken
again by a793564b2591035aec5412fbcbcccf220c773a4c and finally refixed
here.

Basically the functionality was to prompt for login when trying to pull
from the official docker hub.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 4316ae2ed33d158e1d8d994646a75e25a70d9320
Component: engine
2016-04-22 17:14:02 +02:00
03d17b8c5f Update code for latest engine-api
- Update CopyToContainer uses
- Use engine-api/types/versions instead of pkg/version

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 7534f17261d0bb74557ca2f7cd893d5b7b531d49
Component: engine
2016-04-19 16:56:54 +02:00
f8a8c81f4e Merge pull request #21657 from vdemeester/update-engine-api
Update engine api with required arguments
Upstream-commit: 7fd53f7c711474791ce4292326e0b1dc7d4d6b0f
Component: engine
2016-04-18 19:47:22 -07:00
8d9f1bcb22 Merge pull request #21939 from calavera/events_until_past
Get events until a time in the past.
Upstream-commit: 19a453e6b40177af31703f107131aae5ca81adf2
Component: engine
2016-04-15 15:33:41 -04:00
b48cb728b8 Update client code with api changes
Using new methods from engine-api, that make it clearer which element is
required when consuming the API.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: b9c94b70bf2f703f260844b3862a61f93dee6337
Component: engine
2016-04-15 12:48:01 +02:00
de95cbad37 Get events until a time in the past.
This change allow to filter events that happened in the past
without waiting for future events. Example:

docker events --since -1h --until -30m

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 55053d3537100eaeaad9c83b43e31f22d14fde7b
Component: engine
2016-04-14 16:22:16 -07:00
da8ff9f6e7 Merge pull request #21959 from coolljt0725/fix_21957
Fix docker load progressbar, fixes #21957
Upstream-commit: 348d90276802aac6c76126f2fe6866c521190ecd
Component: engine
2016-04-13 00:31:27 -04:00
94711fe63a Fix docker load progressbar, fixes #21957
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: 96d7db665b06cc0bbede22d818c69dc5f6921f66
Component: engine
2016-04-12 22:45:42 -04:00
8194e834c4 Move middleware to interfaces.
This makes separating middlewares from the core api easier.
As an example, the authorization middleware is moved to
it's own package.

Initialize all static middlewares when the server is created, reducing
allocations every time a route is wrapper with the middlewares.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 8d3467626ee26cad48ad84f2181552dce7afccb6
Component: engine
2016-04-11 09:19:27 -07:00
956e3c675e Remove reference package dependency from the api.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 47afe6bd0a0dc806c36d0978a8d3e23f75ef87fe
Component: engine
2016-04-07 15:01:23 -07:00
97016757fb Let client print error when speicify wrong detach keys
Fix #21064

Let client print error message explicitly when user specifies wrong
detach keys.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: 91e5bb954131904af150b06bd22b007559a8ce27
Component: engine
2016-04-04 15:35:55 +08:00
7497562d8e Fix race between with event timer stopping early
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: b38cee9f9c79d1f12001348303b78462d99664ed
Component: engine
2016-03-31 09:49:07 -07:00
b960646c00 Remove builder dependency from the api.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: d12b7c7e3e5566f49f81189b757bcd0e4ef09956
Component: engine
2016-03-29 17:02:36 -07:00
922dd0a9e8 Merge pull request #21586 from calavera/remove_runconfig_from_routes
Remove runconfig package dependency from the API.
Upstream-commit: 1da40fb4badd116a7591dd2c19009146770c9a89
Component: engine
2016-03-29 08:40:49 -07:00
56103ffaad Remove runconfig package dependency from image and container routers.
Use an interface to specify the behavior of a configuration decoder.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: f0d26e1665f7552972db5b041554cc7b45bc3060
Component: engine
2016-03-28 16:23:51 -04:00
91e6a2df59 Remove runconfig dependency from network routes.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 3ca29823d42ab1e2b1ea76981ccc9aa11e858cb2
Component: engine
2016-03-28 16:23:50 -04:00
1660794bad Merge pull request #21523 from LK4D4/cancellable_routes
Embed context.Context to routes with usage of CloseNotify
Upstream-commit: be390c30cdde978ea1a5417875876e4f3ae52655
Component: engine
2016-03-28 12:44:07 -07:00
406cc47308 use router.Cancellable for pull and push
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: c6ad1980a2eb2994940bdf7f79835ffdbed2b44d
Component: engine
2016-03-27 21:53:25 -07:00
ccb887dc36 Extend Docker authorization with TLS user information
Currently Docker authorization framework does not use any user
information, which already available in the Docker context for TLS
connection.
The purpose of this CR is to complete the existing authz work by adding
the basic client certificate details (SUBJECT_NAME) and authentication
method (TLS) to the authz request.

We think this should be the default behavior when no extended
authorization module is specified (currently WIP under #20883).

Signed-off-by: Liron Levin <liron@twistlock.com>
Upstream-commit: 3c157713b31f542a4180e31da4cae7d677330a6f
Component: engine
2016-03-27 15:53:55 +03:00
4948749e40 use router.Cancellable instead of direct CloseNotify
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 62c9e62edcf3d96d251fd06a48437b2fa2f56ad6
Component: engine
2016-03-25 11:33:54 -07:00
f7d7f8e5e6 Merge pull request #21468 from coolljt0725/remove_useless_log
Do not return error on hijacked connection for docker exec
Upstream-commit: e2221d1f37d1204ccca51722aa21fc11939a41ba
Component: engine
2016-03-25 10:50:43 -07:00
96f77f179c api/server/router: add Cancellable function
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: bdd9388c4262d228c57ce637a8e6fad003684df1
Component: engine
2016-03-25 10:19:23 -07:00
43dd16ffb4 builder: replace cancelled channel with net/context
Also stop execution of run immediately if request was cancelled.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: f2401a0f6960734093be307a27bba85a3c2ecfcd
Component: engine
2016-03-25 08:19:29 -07:00
d3972744c1 Merge pull request #21456 from calavera/remove_unecessary_hardcoded_version
Remove unnecessary hardcoded version.
Upstream-commit: 6748ecb0050f2c6a9a57e824f23b5b4afb35240d
Component: engine
2016-03-24 14:31:59 -07:00
2257ef7e0a Remove unnecessary hardcoded version.
The server configuration already keeps the current version
if the daemon. This patch changes the middleware logic
to use it rather than using the global value.

This removes the dockerversion package dependency from the api.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: accf28a7dbdd46203c661d30b80326df4d447cea
Component: engine
2016-03-24 12:33:40 -04:00
afd62f19a9 Do not return error on hijacked connection for docker exec
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: d6ccc0e09fe42d9f0d929dbf8d68ce790f4c8b9e
Component: engine
2016-03-24 08:52:13 -04:00
6cee95ae99 Merge pull request #21268 from calavera/remove_dockerfile_from_api
Remove dockerfile dependency from the API.
Upstream-commit: 5ef04b1c6d1ca94c83c7ce52faae908a278ce6ea
Component: engine
2016-03-23 19:34:21 -07:00
fd6a3ad797 builder: synchronize stderr and stdout
it's concurrent streams and should be synchronized before writing to response.
Otherwise there will be race in writing to *bufio.Writer in
net/http.response.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 3eb0a80f29629a1c022dc914437b176271d476fc
Component: engine
2016-03-22 13:57:29 -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
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
87c76eb0d7 Pass upstream client's user agent through to registry on operations beyond pulls
This adds support for the passthrough on build, push, login, and search.

Revamp the integration test to cover these cases and make it more
robust.

Use backticks instead of quoted strings for backslash-heavy string
contstands.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: c44e7a3e632c3ea961cb8c12ba45371f54e6699c
Component: engine
2016-03-21 14:31:47 -07:00
6c1d291a31 Merge pull request #21306 from mgoelzer/issue20001-nodeps
Pass upstream client's user agent through to registry on image pulls
Upstream-commit: 278d3962a8cb6a42e9841789bdb8b49a29617e24
Component: engine
2016-03-21 14:26:59 -07:00
6143e6c8cf Pass upstream client's user agent through to registry on image pulls
Changes how the Engine interacts with Registry servers on image pull.
Previously, Engine sent a User-Agent string to the Registry server
that included only the Engine's version information.  This commit
appends to that string the fields from the User-Agent sent by the
client (e.g., Compose) of the Engine.  This allows Registry server
operators to understand what tools are actually generating pulls on
their registries.

Signed-off-by: Mike Goelzer <mgoelzer@docker.com>
Upstream-commit: d1502afb63a10df0bfce20ae2957774cfb3e58d8
Component: engine
2016-03-20 04:30:09 -07:00
20351391ce Merge pull request #21274 from jfrazelle/fix-variables-that-werent-being-used
fix variables that werent being called
Upstream-commit: b77573f48e4022c7b8b829c4a33c6963fe08e18a
Component: engine
2016-03-18 18:03:15 -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
91649a03e2 fix typos in several files
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: f1d34ac2eb3611cde8c4a438f367595eb08a6fe8
Component: engine
2016-03-18 12:51:57 +08:00
ae0977f1d1 fix variables that werent being called
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 0e025b4bb16c0d4cc6b3f0c040713d061b9b051a
Component: engine
2016-03-17 13:19:55 -07:00
e4b1dba10c Remove dockerfile dependency from the API.
Move context parsing to the backend.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 93e02efa909896548496a5bd6621221aa541dc50
Component: engine
2016-03-16 22:06:29 -04:00
83045d547d Merge pull request #20970 from dmcgowan/login-oauth
OAuth support for registries
Upstream-commit: b9361f02da25108af75238093959634e433d72a0
Component: engine
2016-03-14 15:49:44 +01:00
10aa342590 Merge pull request #21160 from mavenugo/staleep
Include all endpoints in network inspect object
Upstream-commit: 901c67a8eeabc64e53539b5f3d5aac9c9196a037
Component: engine
2016-03-14 11:36:04 +01:00
f960c0a25f Include all endpoints in network inspect object
Prior to this change, the "docker network inspect" contains only the
endpoints that have active local container. This excludes all the remote
and stale endpoints. By including all the endpoints, it makes debugging
much simpler and also allows the user to cleanup any stale endpoints
using "docker network disconnect -f {network} {endpoint-name}".

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Upstream-commit: 2ef00ba89fc04b0a7571aa050d8a11c06f758d9b
Component: engine
2016-03-13 16:58:53 -07:00
05bbd93137 Merge pull request #20977 from allencloud/fix-delete-response-status-code
return status code http.StatusNoContent in deleting network when OK
Upstream-commit: a04e16ac35e8dd9ec10462cccebf13cf29b49a51
Component: engine
2016-03-13 11:30:32 -04:00
8ca8fa6b76 Add support for identity token with token handler
Use token handler options for initialization.
Update auth endpoint to set identity token in response.
Update credential store to match distribution interface changes.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: e896d1d7c4459c4b357efdd780e9fb9dd9bc90e0
Component: engine
2016-03-09 13:47:57 -08:00
9810cad289 1.return status code http.StatusNoContent in deleting network when successful
2.modify docker_api_network_test.go
3.modify docker_remote_api_v1.23.md

Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 94c929099fdfd200eda90529ae8d2ed90c8e3c97
Component: engine
2016-03-10 00:28:55 +08:00
91e55e2d5c api: server: server: remove redunant debugf
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 526ddd351218798199b6221fad67e1c335ad8542
Component: engine
2016-03-07 09:03:29 +01:00
b8f6e912b7 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 2736f77a94f57ddde5de1e5dc66c168290b91da2
Component: engine
2016-03-06 00:59:11 +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
045d5355a7 Make server middleware standalone functions.
Removing direct dependencies from the server configuration.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1ba44a832f6aae811dfc6235287dd5b99e8aa94c
Component: engine
2016-02-24 14:48:52 -05:00