From f4f83c427cda85cad9636211633ceba459ac661e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 5 Sep 2018 21:57:03 -0700 Subject: [PATCH 1/2] TestServiceWithDefaultAddressPoolInit: avoid panic Saw this in moby ci: > 00:22:07.582 === RUN TestServiceWithDefaultAddressPoolInit > 00:22:08.887 --- FAIL: TestServiceWithDefaultAddressPoolInit (1.30s) > 00:22:08.887 daemon.go:290: [d905878b35bb9] waiting for daemon to start > 00:22:08.887 daemon.go:322: [d905878b35bb9] daemon started > 00:22:08.888 panic: runtime error: index out of range [recovered] > 00:22:08.889 panic: runtime error: index out of range > 00:22:08.889 > 00:22:08.889 goroutine 360 [running]: > 00:22:08.889 testing.tRunner.func1(0xc42069d770) > 00:22:08.889 /usr/local/go/src/testing/testing.go:742 +0x29d > 00:22:08.890 panic(0x85d680, 0xb615f0) > 00:22:08.890 /usr/local/go/src/runtime/panic.go:502 +0x229 > 00:22:08.890 github.com/docker/docker/integration/network.TestServiceWithDefaultAddressPoolInit(0xc42069d770) > 00:22:08.891 /go/src/github.com/docker/docker/integration/network/service_test.go:348 +0xb53 > ..... Apparently `out.IPAM.Config[0]` is not there, so to avoid panic, let's check the size of `out.IPAM.Config` first. Fixes: f7ad95cab9c [v2: add logging of data returned by NetworkInspect()] [v3: use assert.Assert to fail immediately] Signed-off-by: Kir Kolyshkin (cherry picked from commit 69d3a8936b8d91e43290aadb9f7ac2cd2929dc61) Signed-off-by: Sebastiaan van Stijn Upstream-commit: f43fc6650cf5a452157fe081086098c124a426fd Component: engine --- components/engine/integration/network/service_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/engine/integration/network/service_test.go b/components/engine/integration/network/service_test.go index fb5ca9e6e9..739a8ecb7d 100644 --- a/components/engine/integration/network/service_test.go +++ b/components/engine/integration/network/service_test.go @@ -345,6 +345,8 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) { out, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) assert.NilError(t, err) + t.Logf("%s: NetworkInspect: %+v", t.Name(), out) + assert.Assert(t, len(out.IPAM.Config) > 0) assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.0.0/24") err = cli.ServiceRemove(context.Background(), serviceID) From 812694c0cc738ef2eea22f9b52ce86522da27aa5 Mon Sep 17 00:00:00 2001 From: Anda Xu Date: Mon, 17 Sep 2018 15:28:26 -0700 Subject: [PATCH 2/2] fixed the dockerd won't start bug when 'runtimes' field is defined in both daemon config file and cli flags Signed-off-by: Anda Xu (cherry picked from commit 8392d0930b511402aa7aa71ccfe6c0d4a8159237) Upstream-commit: 66ed41aec82dbcdfbc38027e3d800e429af1cd58 Component: engine --- components/engine/daemon/config/config.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/engine/daemon/config/config.go b/components/engine/daemon/config/config.go index 451078d8c5..9f215e3068 100644 --- a/components/engine/daemon/config/config.go +++ b/components/engine/daemon/config/config.go @@ -64,6 +64,16 @@ var skipValidateOptions = map[string]bool{ "features": true, } +// skipDuplicates contains configuration keys that +// will be skipped when checking duplicated +// configuration field defined in both daemon +// config file and from dockerd cli flags. +// This allows some configurations to be merged +// during the parsing. +var skipDuplicates = map[string]bool{ + "runtimes": true, +} + // LogConfig represents the default log configuration. // It includes json tags to deserialize configuration from a file // using the same names that the flags in the command line use. @@ -491,13 +501,13 @@ func findConfigurationConflicts(config map[string]interface{}, flags *pflag.Flag duplicatedConflicts := func(f *pflag.Flag) { // search option name in the json configuration payload if the value is a named option if namedOption, ok := f.Value.(opts.NamedOption); ok { - if optsValue, ok := config[namedOption.Name()]; ok { + if optsValue, ok := config[namedOption.Name()]; ok && !skipDuplicates[namedOption.Name()] { conflicts = append(conflicts, printConflict(namedOption.Name(), f.Value.String(), optsValue)) } } else { // search flag name in the json configuration payload for _, name := range []string{f.Name, f.Shorthand} { - if value, ok := config[name]; ok { + if value, ok := config[name]; ok && !skipDuplicates[name] { conflicts = append(conflicts, printConflict(name, f.Value.String(), value)) break }