Browse code

Merge pull request #40510 from aiordache/moby_cluster_flags_deprecate

Deprecate '--cluster-xx' options and add warning

Brian Goff authored on 2020/02/28 04:25:31
Showing 2 changed files
... ...
@@ -68,9 +68,14 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
68 68
 	flags.Var(opts.NewNamedListOptsRef("labels", &conf.Labels, opts.ValidateLabel), "label", "Set key=value labels to the daemon")
69 69
 	flags.StringVar(&conf.LogConfig.Type, "log-driver", "json-file", "Default driver for container logs")
70 70
 	flags.Var(opts.NewNamedMapOpts("log-opts", conf.LogConfig.Config, nil), "log-opt", "Default log driver options for containers")
71
+
71 72
 	flags.StringVar(&conf.ClusterAdvertise, "cluster-advertise", "", "Address or interface name to advertise")
73
+	_ = flags.MarkDeprecated("cluster-advertise", "Swarm classic is deprecated. Please use Swarm-mode (docker swarm init)")
72 74
 	flags.StringVar(&conf.ClusterStore, "cluster-store", "", "URL of the distributed storage backend")
75
+	_ = flags.MarkDeprecated("cluster-store", "Swarm classic is deprecated. Please use Swarm-mode (docker swarm init)")
73 76
 	flags.Var(opts.NewNamedMapOpts("cluster-store-opts", conf.ClusterOpts, nil), "cluster-store-opt", "Set cluster store options")
77
+	_ = flags.MarkDeprecated("cluster-store-opts", "Swarm classic is deprecated. Please use Swarm-mode (docker swarm init)")
78
+
74 79
 	flags.StringVar(&conf.CorsHeaders, "api-cors-header", "", "Set CORS headers in the Engine API")
75 80
 	flags.IntVar(&maxConcurrentDownloads, "max-concurrent-downloads", config.DefaultMaxConcurrentDownloads, "Set the max concurrent downloads for each pull")
76 81
 	flags.IntVar(&maxConcurrentUploads, "max-concurrent-uploads", config.DefaultMaxConcurrentUploads, "Set the max concurrent uploads for each push")
... ...
@@ -85,6 +85,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
85 85
 	if cli.Config, err = loadDaemonCliConfig(opts); err != nil {
86 86
 		return err
87 87
 	}
88
+	warnOnDeprecatedConfigOptions(cli.Config)
88 89
 
89 90
 	if err := configureDaemonLogs(cli.Config); err != nil {
90 91
 		return err
... ...
@@ -444,6 +445,18 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
444 444
 	return conf, nil
445 445
 }
446 446
 
447
+func warnOnDeprecatedConfigOptions(config *config.Config) {
448
+	if config.ClusterAdvertise != "" {
449
+		logrus.Warn(`The "cluster-advertise" option is deprecated. To be removed soon.`)
450
+	}
451
+	if config.ClusterStore != "" {
452
+		logrus.Warn(`The "cluster-store" option is deprecated. To be removed soon.`)
453
+	}
454
+	if len(config.ClusterOpts) > 0 {
455
+		logrus.Warn(`The "cluster-store-opt" option is deprecated. To be removed soon.`)
456
+	}
457
+}
458
+
447 459
 func initRouter(opts routerOptions) {
448 460
 	decoder := runconfig.ContainerDecoder{}
449 461