mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
cmd/dockerd: produce error when using discovery options
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
65b92a730a
commit
9f2240c56f
2 changed files with 9 additions and 19 deletions
|
@ -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) {
|
||||
|
|
|
@ -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"]))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue