Commit Graph

404 Commits

Author SHA1 Message Date
a76e16e99f Windows libcontainerd implementation
Signed-off-by: John Howard <jhoward@microsoft.com>
Signed-off-by: John Starks <jostarks@microsoft.com>
Signed-off-by: Darren Stahl <darst@microsoft.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 94d70d835500bec3b171425271916d3e40f29635
Component: engine
2016-03-18 13:38:41 -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
79f5e01124 Windows: add support for CloseWrite() to npipe transport
This relies on changes to go-winio to support CloseWrite() when the pipe
is in message mode. This fixes an issue where stdin is not properly closed
when there is no more input to docker run.

Signed-off-by: John Starks <jostarks@microsoft.com>
Upstream-commit: 59573fb3c6e8e55278c973b9c799db6ed9c0f9c7
Component: engine
2016-03-15 18:25:35 -07:00
f4df2c2057 Windows CI: Fix unit test failures
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 1fbaf6ee8b6cd0c149472bf465bbffb4e78f8b96
Component: engine
2016-03-11 19:31:08 -08:00
19d229cc30 Merge pull request #20476 from wenchma/19425-TestDaemonStartWithDaemonCommand
Optimize slow bottleneck tests of TestDaemonStartWithDaemonCommand
Upstream-commit: 1c0474ed63ac08a3e280ecf7eebcb9e53ae92c8d
Component: engine
2016-03-11 10:54:48 -05:00
91021f9750 Move registry service options to the daemon configuration.
Allowing to set their values in the daemon configuration file.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 59586d02b1cc004f14cd7ff6b454211f562da326
Component: engine
2016-03-10 11:53:11 -05:00
7d7a36d3ff Optimize slow bottleneck tests of TestDaemonStartWithDaemonCommand
* Remvoe integration test of TestDaemonStartWithDaemonCommand
* Rewrite as unit test

Related issue #19425

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
Upstream-commit: b9ef2682b905bf0403fd03d697a6d7a93d91a587
Component: engine
2016-03-01 14:05:39 +08:00
5954e87608 Windows CI: Unit Test move Unix specific struct field tests to _unix.go
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 957792e485a58698ad374c5a69157d9afa7879a2
Component: engine
2016-02-29 18:04:06 -08:00
5f0c16d34d Merge pull request #20604 from coolljt0725/fix_reload
Fix configuration reloading
Upstream-commit: 20a038eca68e4188e1cd812293aea8cb220cf08f
Component: engine
2016-02-29 07:14:15 +01: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
ba3d7fd0c4 Fix configuration reloading
There are five options 'debug' 'labels' 'cluster-store' 'cluster-store-opts'
and 'cluster-advertise' that can be reconfigured, configure any of these
options should not affect other options which may have configured in flags.
But this is not true, for example, I start a daemon with -D to enable the
debugging, and after a while, I want reconfigure the 'label', so I add a file
'/etc/docker/daemon.json' with content '"labels":["test"]' and send SIGHUP to daemon
to reconfigure the daemon, it work, but the debugging of the daemon is also diabled.
I don't think this is a expeted behaviour.
This patch also have some minor refactor of reconfiguration of cluster-advertiser.
Enable user to reconfigure cluster-advertiser without cluster-store in config file
since cluster-store could also be already set in flag, and we only want to reconfigure
the cluster-advertiser.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: b9366c9609166d41e987608041b5a2079726aa5f
Component: engine
2016-02-24 21:12:14 -05:00
05fbdefd70 Add check for non-systemd fd use case
We make the check more user-friendly, and users can learn
start docker with wrong fd used.

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
Upstream-commit: 3c69d340ebe35dc3adb56cd2345cbac3c1dd5fb8
Component: engine
2016-02-22 01:53:38 +00:00
2625f17a24 Avoid setting default truthy values from flags that are not set.
When the value for a configuration option in the file is `false`,
and the default value for a flag is `true`, we should not
take the value from the later as final value for the option,
because the user explicitly set `false`.

This change overrides the default value in the flagSet with
the value in the configuration file so we get the correct
result when we merge the two configurations together.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 31cb96dcfaaebe3f807e7c7bf82a48b5995c743b
Component: engine
2016-02-19 18:39:10 -05:00
ab0cee0d5e 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>
Upstream-commit: e8f569b3246b3ce4e765b0aafe53b6d70d12a2d6
Component: engine
2016-02-16 14:11:16 -05:00
c9c9d43ade Move listeners and port allocation outside the server.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 34c29277c2c1fd1d1adc4409dc7075685f681de4
Component: engine
2016-02-11 14:42:49 -05:00
5c97141da9 Remove daemon dependency from api/server.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1af76ef5970202bdbc7024d825c0fcfcc4ec6ede
Component: engine
2016-02-10 15:16:59 -05:00
43913f9547 Merge pull request #19911 from Microsoft/jstarks/npipe
Windows: Add support for named pipe protocol
Upstream-commit: 83ee24e52b04fd8cf1f7366dff04baa43d89ec49
Component: engine
2016-02-02 15:59:45 -08:00
46e42d4581 Add regression tests for client debug flag.
- Add client debug info to the `docker info` command.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 9f315dd328a33b51133a41067a508a8b59166a39
Component: engine
2016-02-02 16:57:36 -05:00
bfd1c80469 Make sure flat options are not parsed as config structures.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: b6766e3063dccfc58c0ab1cfc9687cfa2947be6a
Component: engine
2016-02-02 14:45:37 -05:00
27daf9cbce 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>
Upstream-commit: 0906195fbbd6f379c163b80f23e4c5a60bcfc5f0
Component: engine
2016-02-01 19:46:30 -08:00
252a3f9cb5 Merge pull request #19794 from calavera/14358-disable-colors
[Carry 18621] Allow disabling of colored Docker logs via daemon flag.
Upstream-commit: 85475f7deabed7d94e98321bdb190f7eb756eaec
Component: engine
2016-02-01 15:37:44 -08:00
fb14e6604b Allow disabling of colored Docker logs via daemon flag.
Signed-off-by: Vincent Woo <me@vincentwoo.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 87a450a37f0e934b67c90fbcdbff28459216e332
Component: engine
2016-02-01 16:19:18 -05:00
2dcfdf5354 handle debug mode for clients
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 78b0defcf344294874202e819dcb3f8a0daedf43
Component: engine
2016-02-01 14:36:40 -05:00
3ec10b17fa Allow network configuration via daemon config file.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: c539be88332815aeb2d466a973443127c1c676a6
Component: engine
2016-01-25 18:54:56 -05:00
9aa26ba55a Make TLSOptions and LogConfig embedded structs.
That way the configuration file becomes flag, without extra keys.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 5e80ac0dd183874ab7cd320a8bd0f0378dbd1321
Component: engine
2016-01-22 13:20:17 -05:00
a73130b07f Verify that the configuration keys in the file are valid.
- Return an error if any of the keys don't match valid flags.
- Fix an issue ignoring merged values as named values.
- Fix tlsverify configuration key.
- Fix bug in mflag to avoid panics when one of the flag set doesn't have any flag.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: ed4038676f09d124180d634ec2cb341745f5fc79
Component: engine
2016-01-21 16:56:12 -05:00
55307d5648 Fix post config verification without flags.
- Set the daemon log level to what's set in the configuration.
- Enable TLS when TLSVerify is enabled.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: cd3446972e968639684f2b65bfc11c099a25f1b0
Component: engine
2016-01-20 13:01:07 -05:00
1a8f320266 Allow to set daemon and server configurations in a file.
Read configuration after flags making this the priority:

1- Apply configuration from file.
2- Apply configuration from flags.

Reload configuration when a signal is received, USR2 in Linux:

- Reload router if the debug configuration changes.
- Reload daemon labels.
- Reload cluster discovery.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 677a6b3506107468ed8c00331991afd9176fa0b9
Component: engine
2016-01-14 16:44:37 -05:00
460be1e8dd Rename authz to authorization for greater clarity
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 5c630ea7c3d5e7a24e1c4b2e15506f326706e9bc
Component: engine
2016-01-13 14:15:37 -05:00
20f675aab6 replace the os.Stdout with stdout to adapt platform
Signed-off-by: Sun Gengze <690388648@qq.com>
Upstream-commit: 1cb9b0745c225433758397606a5ccd8404cb575e
Component: engine
2015-12-30 18:24:02 +08:00
51b37769f0 Remove usage of pkg sockets and tlsconfig.
- Use the ones provided by docker/go-connections, they are a drop in replacement.
- Remove pkg/sockets from docker.
- Keep pkg/tlsconfig because libnetwork still needs it and there is a
  circular dependency issue.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 8e034802b7ad92a29f08785e553415adcd1348a3
Component: engine
2015-12-29 19:27:12 -05:00
2526161bde Remove the graph driver from the daemon, move it into the layer store.
Support restoreCustomImage for windows with a new interface to extract
the graph driver from the LayerStore.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: f5916b10ae02c7db83052a97205ac345a3d96300
Component: engine
2015-12-28 12:55:48 -05:00
7f43cd332d Move timeutils functions to the only places where they are used.
- Move time json marshaling to the jsonlog package: this is a docker
  internal hack that we should not promote as a library.
- Move Timestamp encoding/decoding functions to the API types: This is
  only used there. It could be a standalone library but I don't this
it's worth having a separated repo for this. It could introduce more
complexity than it solves.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 27220ecc6b1eedf650ca9cf94965cb0dc2054efd
Component: engine
2015-12-15 14:56:14 -05:00
2491643ccf Docker authorization plug-in infrastructure enables extending the functionality of the Docker daemon with respect to user authorization. The infrastructure enables registering a set of external authorization plug-in. Each plug-in receives information about the user and the request and decides whether to allow or deny the request. Only in case all plug-ins allow accessing the resource the access is granted.
Each plug-in operates as a separate service, and registers with Docker
through general (plug-ins API)
[https://blog.docker.com/2015/06/extending-docker-with-plugins/]. No
Docker daemon recompilation is required in order to add / remove an
authentication plug-in. Each plug-in is notified twice for each
operation: 1) before the operation is performed and, 2) before the
response is returned to the client. The plug-ins can modify the response
that is returned to the client.

The authorization depends on the authorization effort that takes place
in parallel [https://github.com/docker/docker/issues/13697].

This is the official issue of the authorization effort:
https://github.com/docker/docker/issues/14674

(Here)[https://github.com/rhatdan/docker-rbac] you can find an open
document that discusses a default RBAC plug-in for Docker.

Signed-off-by: Liron Levin <liron@twistlock.com>
Added container create flow test and extended the verification for ps
Upstream-commit: 75c353f0ad73bd83ed18e92857dd99a103bb47e3
Component: engine
2015-12-08 17:34:15 +02:00
59911bba39 Remove usage of listenbuffer package
It actually adds nothing to queuing requests.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: ca5795cef810c85f101eb0aa3efe3ec8d756490b
Component: engine
2015-11-30 09:04:55 -08:00
c862a7ae5b Revert "Return listenbuffer behavior"
This reverts commit 281a48d092fa84500c63b984ad45c59a06f301c4.

Signed-off-by: Alex Crawford <alex.crawford@coreos.com>
Upstream-commit: a8b84cd8fb63d237b488f8b137b45187a6efaa5a
Component: engine
2015-11-24 18:32:57 -08:00
d1d856514e Fix "./docker" package name on freebsd
This fixes "can't load package: package ./docker: found packages client.go (main) and daemon_freebsd.go (docker)"

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
Upstream-commit: e54c4517a78ea87e6611784f9900e82f60a23303
Component: engine
2015-11-17 09:38:19 -08:00
2e538bcbf1 Remove deprecated cli flags
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 7929888214741c4ab194c44e0b14ac08aca06556
Component: engine
2015-11-15 10:40:01 +01:00
2f262fa249 Merge pull request #17431 from vdemeester/hope-it-does-not-broke-everything-again
Another try at dockerversion placeholder for library import
Upstream-commit: 58b270c338e831ac6668a29788c72d202f9fc251
Component: engine
2015-11-09 13:15:50 -08:00
48001c30bb dockerversion placeholder for library import
- Add a *version* file placeholder.
- Update autogen and builds to use it and an autogen build flag

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 8054a303870b81eebe05e38261c1b68197b68558
Component: engine
2015-11-09 19:32:46 +01:00
ef88e7ace2 Remove LXC support.
The LXC driver was deprecated in Docker 1.8.
Following the deprecation rules, we can remove a deprecated feature
after two major releases. LXC won't be supported anymore starting on Docker 1.10.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 3b5fac462d21ca164b3778647420016315289034
Component: engine
2015-11-05 17:09:57 -05:00
cc55863497 Revert "dockerversion placeholder for library-import"
This reverts commit d5cd032a86617249eadd7142227c5355ba9164b4.

Commit caused issues on systems with case-insensitive filesystems.
Revert for now

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b78ca243d9fc25d81c1b50008ee69f3e71e940f6
Component: engine
2015-10-27 21:23:53 -04:00
4d261096ec dockerversion placeholder for library-import
- Move autogen/dockerversion to version
- Update autogen and "builds" to use this package and a build flag

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: d5cd032a86617249eadd7142227c5355ba9164b4
Component: engine
2015-10-27 20:36:07 +01:00
f833d205f0 Make default tls host work
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: fbb01b816288c5cf3eb79358c035072766b6e0f0
Component: engine
2015-10-19 21:17:37 +08:00
0e3861a2d2 Merge pull request #16910 from mavenugo/ipam
Vendoring libnetwork for the pluggable IPAM driver support
Upstream-commit: 4ea3ff70618d28520d2ae787bd00206d05c9f1db
Component: engine
2015-10-13 14:41:19 -07:00
7a285e518e IPAM API & UX
introduced --subnet, --ip-range and --gateway options in docker network
command. Also, user can allocate driver specific ip-address if any using
the --aux-address option.
Supports multiple subnets per network and also sharing ip range
across networks if the network-driver and ipam-driver supports it.
Example, Bridge driver doesnt support sharing same ip range across
networks.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Upstream-commit: cc6aece1fdefbc10638fe9e462a15608c6093115
Component: engine
2015-10-13 11:03:03 -07:00
7c902d7e22 Merge pull request #16928 from coolljt0725/fix_16927
Fix docker daemon exit immediately after starting without -H option closes #16927
Upstream-commit: 08c5f52d70e539ff168d570b60b0c5d6c1a847c2
Component: engine
2015-10-12 17:24:42 +02:00
eaf757b644 Fix docker daemon exit immediately after starting without -H option closes #16927
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: e38767e197a1456458cda53b4558f56f5b6f22fa
Component: engine
2015-10-12 04:49:25 -04:00
bb94a5ee85 Remove used param on ParseHost
The first param on opts.ParseHost() wasn't being used for anything.

Once we get rid of that param we can then also clean-up some code
that calls ParseHost() because the param that was passed in wasn't
being used for anything else.

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: ba973f2d74c150154390aed1a5aed8fb5d0673b8
Component: engine
2015-10-11 20:45:17 -07:00
b34ed2cbab Merge pull request #15753 from SvenDowideit/make-windows-default-to-use-2376
Default the tcp port to 2376 if tls is on, and 2375 if not
Upstream-commit: c45ad0b02d1cc1f88aaabab18aed27aeb20b9e7a
Component: engine
2015-10-11 15:35:04 -07:00