Commit graph

653 commits

Author SHA1 Message Date
Alexander Morozov
3eb0a80f29 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>
2016-03-22 13:57:29 -07:00
Tibor Vass
53d2e5e9d7 Merge pull request #21270 from ehazlett/resource-labels
Add Label support for Images (build), Networks and Volumes on Creation
2016-03-22 15:12:33 -04:00
Evan Hazlett
fc214b4408 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>
2016-03-22 11:49:06 -04:00
Aaron Lehmann
c44e7a3e63 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>
2016-03-21 14:31:47 -07:00
Arnaud Porterie
278d3962a8 Merge pull request #21306 from mgoelzer/issue20001-nodeps
Pass upstream client's user agent through to registry on image pulls
2016-03-21 14:26:59 -07:00
Mike Goelzer
d1502afb63 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>
2016-03-20 04:30:09 -07:00
Jess Frazelle
b77573f48e Merge pull request #21274 from jfrazelle/fix-variables-that-werent-being-used
fix variables that werent being called
2016-03-18 18:03:15 -07:00
Tonis Tiigi
9c4570a958 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>
2016-03-18 13:38:32 -07:00
allencloud
f1d34ac2eb fix typos in several files
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-03-18 12:51:57 +08:00
Jessica Frazelle
0e025b4bb1
fix variables that werent being called
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-03-17 13:19:55 -07:00
Vincent Demeester
b9361f02da Merge pull request #20970 from dmcgowan/login-oauth
OAuth support for registries
2016-03-14 15:49:44 +01:00
Vincent Demeester
901c67a8ee Merge pull request #21160 from mavenugo/staleep
Include all endpoints in network inspect object
2016-03-14 11:36:04 +01:00
Madhu Venugopal
2ef00ba89f 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>
2016-03-13 16:58:53 -07:00
Brian Goff
a04e16ac35 Merge pull request #20977 from allencloud/fix-delete-response-status-code
return status code http.StatusNoContent in deleting network when OK
2016-03-13 11:30:32 -04:00
Derek McGowan
e896d1d7c4 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)
2016-03-09 13:47:57 -08:00
allencloud
94c929099f 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>
2016-03-10 00:28:55 +08:00
Antonio Murdaca
526ddd3512 api: server: server: remove redunant debugf
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-03-07 09:03:29 +01:00
allencloud
2736f77a94 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-03-06 00:59:11 +08:00
David Calavera
a793564b25 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>
2016-02-26 15:49:09 -05:00
David Calavera
1ba44a832f Make server middleware standalone functions.
Removing direct dependencies from the server configuration.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-24 14:48:52 -05:00
Brent Salisbury
a499ad8e4e Fixed logrus client/server mismatch debug msg
Signed-off-by: Brent Salisbury <brent@docker.com>
2016-02-22 23:36:33 -05:00
Morgan Bauer
9021506502
consistent variable names in api/server/router
- banish 'daemon'

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
2016-02-22 10:53:47 -08:00
Zhang Wei
ff3ea4c90f 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>
2016-02-20 17:06:32 +08:00
David Calavera
2e6c841b82 Merge pull request #17513 from aidanhs/aphs-expose-ipv6-default-bridge
Expose bridge IPv6 setting to `docker network inspect`
2016-02-18 10:35:04 -08:00
David Calavera
e8f569b324 Remove all docker debugging knowledge from the server.
It should be explicitly told whether to enable the profiler or not.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-16 14:11:16 -05:00
Jess Frazelle
64a4605892 Merge pull request #20278 from aaronlehmann/build-authconfig
Pass authentication credentials through to build
2016-02-12 18:37:49 -05:00
Doug Davis
059ad5d0a9 Lower warning about old client to a debug
Ideally I would love to just remove this check entirely because its
seems pretty useless.  An old client talking to a new server isn't
an error condition, nor is it something to even worry about - its a normal
part of life.  Flooding my screen (and logs) with a warning that isn't
something I (as an admin) need to be concerned about is silly and a
distraction when I need to look for real issues.  If anything this should
be printed on the cli not the daemon since its the cli that needs to be
concerned, not the daemon.

However, since when you debug an issue it might be interesting to know the
client is old I decided to pull back a little and just change it from
a Warning to a Debug logrus call instead.

If others want it removed I still do that though  :-)

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-02-12 10:53:40 -08:00
Aaron Lehmann
6fed46aeb9 Pass authentication credentials through to build
In Docker 1.10 and earlier, "docker build" can do a build FROM a private
repository that hasn't yet been pulled. This doesn't work on master. I
bisected this to https://github.com/docker/docker/pull/19414.
AuthConfigs is deserialized from the HTTP request, but not included in
the builder options.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-12 10:50:16 -08:00
Aidan Hobson Sayers
dfb00652aa Expose bridge IPv6 setting to docker network inspect
Signed-off-by: Aidan Hobson Sayers <aidanhs@cantab.net>
2016-02-11 22:13:47 +00:00
David Calavera
34c29277c2 Move listeners and port allocation outside the server.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-11 14:42:49 -05:00
John Howard
d4b0732499 Windows: Fix 'isolation'
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-10 13:19:19 -08:00
David Calavera
1af76ef597 Remove daemon dependency from api/server.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-10 15:16:59 -05:00
Brian Goff
a77b7dd227 cleanup attach api calls
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-02-09 14:26:51 -05:00
Brian Goff
ae4ee974e8 Move stream flushes to backend
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-02-09 14:25:02 -05:00
David Calavera
06d8f504f7 Move backend types to their own package.
- Remove duplicated structs that we already have in engine-api.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-08 12:42:17 -05:00
Lukas Waslowski
dd93571c69 Decouple the "container" router from the actual daemon implementation.
This is done by moving the following types to api/types/config.go:
  - ContainersConfig
  - ContainerAttachWithLogsConfig
  - ContainerWsAttachWithLogsConfig
  - ContainerLogsConfig
  - ContainerStatsConfig

Remove dependency on "version" package from types.ContainerStatsConfig.
Decouple the "container" router from the "daemon/exec" implementation.

* This is done by making daemon.ContainerExecInspect() return an interface{}
value. The same trick is already used by daemon.ContainerInspect().

Improve documentation for router packages.
Extract localRoute and router into separate files.
Move local.router to image.imageRouter.

Changes:
  - Move local/image.go to image/image_routes.go.
  - Move local/local.go to image/image.go
  - Rename router to imageRouter.
  - Simplify imports for image/image.go (remove alias for router package).

Merge router/local package into router package.
Decouple the "image" router from the actual daemon implementation.
Add Daemon.GetNetworkByID and Daemon.GetNetworkByName.
Decouple the "network" router from the actual daemon implementation.

This is done by replacing the daemon.NetworkByName constant with
an explicit GetNetworkByName method.

Remove the unused Daemon.GetNetwork method and the associated constants NetworkByID and NetworkByName.

Signed-off-by: Lukas Waslowski <cr7pt0gr4ph7@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-08 11:30:57 -05:00
Lei Jitang
fae09e2569 Add progress bar to docker load
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-02-05 02:24:23 -05:00
Chun Chen
c199506b59 Display internal flag on network inspect
Also adds internal network tests for bridge network

Signed-off-by: Chun Chen <ramichen@tencent.com>
2016-02-04 15:28:37 +08:00
Alexander Morozov
83ee24e52b Merge pull request #19911 from Microsoft/jstarks/npipe
Windows: Add support for named pipe protocol
2016-02-02 15:59:45 -08:00
Victor Vieux
0fd9b4067d fix error message on version too low
Signed-off-by: Victor Vieux <vieux@docker.com>
2016-02-02 14:16:15 -08:00
John Starks
0906195fbb Windows: Add support for named pipe protocol
This adds an npipe protocol option for Windows hosts, akin to unix
sockets for Linux hosts. This should become the default transport
for Windows, but this change does not yet do that.

It also does not add support for the client side yet since that
code is in engine-api, which will have to be revendored separately.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-02-01 19:46:30 -08:00
Anusha Ragunathan
9c332b164f Remove package daemonbuilder.
Currently, daemonbuilder package (part of daemon) implemented the
builder backend. However, it was a very thin wrapper around daemon
methods and caused an implementation dependency for api/server build
endpoint. api/server buildrouter should only know about the backend
implementing the /build API endpoint.

Removing daemonbuilder involved moving build specific methods to
respective files in the daemon, where they fit naturally.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-02-01 09:57:38 -08:00
Brian Goff
d695cf8de7 Merge pull request #19638 from runcom/remove-redunant-function
cleanup and move stuff where needed
2016-01-30 10:12:38 -05:00
Zhang Wei
98f74f8383 Change log level
Warning should be printed with real `logrus.Warn`

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-01-30 18:46:16 +08:00
Antonio Murdaca
a7d1aeceec postImagesCreate: move auth config decode when it's needed
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-01-29 14:07:54 +01:00
Brian Goff
0b7acaf4b9 Merge pull request #19733 from calavera/auth_error_on_post_create
Respond with 401 when there is an unauthorized error from the registry.
2016-01-28 13:44:58 -05:00
David Calavera
7bca932182 Respond with 401 when there is an unauthorized error from the registry.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-01-27 13:55:33 -05:00
Aidan Hobson Sayers
ada7920479 Permit OPTIONS request against any url, fixes #19398
Signed-off-by: Aidan Hobson Sayers <aidanhs@cantab.net>
2016-01-23 00:31:08 +00:00
Alexander Morozov
3dc8829a83 Remove obsolete comment
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-01-19 12:17:40 -08:00
Brian Goff
b6be645197 Merge pull request #19420 from clnperez/close-notify-fix
Move closeNotify to fix panic with newer golang
2016-01-18 20:08:25 -05:00