From 9f2240c56fb0aeeb286b54528b90dc62716b5614 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 15 Dec 2021 23:51:57 +0100 Subject: [PATCH] cmd/dockerd: produce error when using discovery options Signed-off-by: Sebastiaan van Stijn --- cmd/dockerd/daemon.go | 19 ++++++++----------- cmd/dockerd/daemon_unix_test.go | 9 +-------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index 2c9ae2951b..54a85b651f 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -80,6 +80,9 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) { if cli.Config, err = loadDaemonCliConfig(opts); err != nil { return err } + if err := checkDeprecatedOptions(cli.Config); err != nil { + return err + } if opts.Validate { // If config wasn't OK we wouldn't have made it this far. @@ -89,8 +92,6 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) { configureProxyEnv(cli.Config) - warnOnDeprecatedConfigOptions(cli.Config) - if err := configureDaemonLogs(cli.Config); err != nil { return err } @@ -465,16 +466,12 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) { return conf, nil } -func warnOnDeprecatedConfigOptions(config *config.Config) { - if config.ClusterAdvertise != "" { - logrus.Warn(`The "cluster-advertise" option is deprecated. To be removed soon.`) - } - if config.ClusterStore != "" { - logrus.Warn(`The "cluster-store" option is deprecated. To be removed soon.`) - } - if len(config.ClusterOpts) > 0 { - logrus.Warn(`The "cluster-store-opt" option is deprecated. To be removed soon.`) +func checkDeprecatedOptions(config *config.Config) error { + // Overlay networks with external k/v stores have been deprecated + if config.ClusterAdvertise != "" || len(config.ClusterOpts) > 0 || config.ClusterStore != "" { + return errors.New("Host-discovery and overlay networks with external k/v stores are deprecated. The 'cluster-advertise', 'cluster-store', and 'cluster-store-opt' options have been removed") } + return nil } func initRouter(opts routerOptions) { diff --git a/cmd/dockerd/daemon_unix_test.go b/cmd/dockerd/daemon_unix_test.go index 4ead3d2d3d..81cf0d1c05 100644 --- a/cmd/dockerd/daemon_unix_test.go +++ b/cmd/dockerd/daemon_unix_test.go @@ -48,10 +48,7 @@ func TestLoadDaemonConfigWithNetwork(t *testing.T) { } func TestLoadDaemonConfigWithMapOptions(t *testing.T) { - content := `{ - "cluster-store-opts": {"kv.cacertfile": "/var/lib/docker/discovery_certs/ca.pem"}, - "log-opts": {"tag": "test"} -}` + content := `{"log-opts": {"tag": "test"}}` tempFile := fs.NewFile(t, "config", fs.WithContent(content)) defer tempFile.Remove() @@ -59,10 +56,6 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) { loadedConfig, err := loadDaemonCliConfig(opts) assert.NilError(t, err) assert.Assert(t, loadedConfig != nil) - assert.Check(t, loadedConfig.ClusterOpts != nil) - - expectedPath := "/var/lib/docker/discovery_certs/ca.pem" - assert.Check(t, is.Equal(expectedPath, loadedConfig.ClusterOpts["kv.cacertfile"])) assert.Check(t, loadedConfig.LogConfig.Config != nil) assert.Check(t, is.Equal("test", loadedConfig.LogConfig.Config["tag"])) }