ソースを参照

d/config: fix default-network-opts in daemon.json

Prevent the daemon from erroring out if daemon.json contains default
network options for network drivers aside from bridge. Configuring
defaults for the bridge driver previously worked by coincidence because
the unrelated CLI flag '--bridge' exists.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 2 年 前
コミット
750218c5e5
2 ファイル変更13 行追加6 行削除
  1. 7 6
      daemon/config/config.go
  2. 6 0
      daemon/config/config_linux_test.go

+ 7 - 6
daemon/config/config.go

@@ -76,12 +76,13 @@ var builtinRuntimes = map[string]bool{
 // Use this to differentiate these options
 // Use this to differentiate these options
 // with others like the ones in TLSOptions.
 // with others like the ones in TLSOptions.
 var flatOptions = map[string]bool{
 var flatOptions = map[string]bool{
-	"cluster-store-opts": true,
-	"log-opts":           true,
-	"runtimes":           true,
-	"default-ulimits":    true,
-	"features":           true,
-	"builder":            true,
+	"cluster-store-opts":   true,
+	"default-network-opts": true,
+	"log-opts":             true,
+	"runtimes":             true,
+	"default-ulimits":      true,
+	"features":             true,
+	"builder":              true,
 }
 }
 
 
 // skipValidateOptions contains configuration keys
 // skipValidateOptions contains configuration keys

+ 6 - 0
daemon/config/config_linux_test.go

@@ -25,6 +25,11 @@ func TestGetConflictFreeConfiguration(t *testing.T) {
 			},
 			},
 			"log-opts": {
 			"log-opts": {
 				"tag": "test_tag"
 				"tag": "test_tag"
+			},
+			"default-network-opts": {
+				"overlay": {
+					"com.docker.network.driver.mtu": "1337"
+				}
 			}
 			}
 		}`)
 		}`)
 
 
@@ -33,6 +38,7 @@ func TestGetConflictFreeConfiguration(t *testing.T) {
 	flags.BoolVarP(&debug, "debug", "D", false, "")
 	flags.BoolVarP(&debug, "debug", "D", false, "")
 	flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "")
 	flags.Var(opts.NewNamedUlimitOpt("default-ulimits", nil), "default-ulimit", "")
 	flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "")
 	flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "")
+	flags.Var(opts.NewNamedMapMapOpts("default-network-opts", nil, nil), "default-network-opt", "")
 
 
 	cc, err := getConflictFreeConfiguration(configFile, flags)
 	cc, err := getConflictFreeConfiguration(configFile, flags)
 	assert.NilError(t, err)
 	assert.NilError(t, err)