Browse code

Revert openshift sdn plugin auto detection on the node

Ravi Sankar Penta authored on 2016/09/01 07:10:30
Showing 7 changed files
... ...
@@ -95,7 +95,7 @@ func NewCommandNodeConfig(commandName string, fullName string, out io.Writer) *c
95 95
 	flags.StringVar(&options.NodeClientCAFile, "node-client-certificate-authority", options.NodeClientCAFile, "The file containing signing authorities to use to verify requests to the node. If empty, all requests will be allowed.")
96 96
 	flags.StringVar(&options.APIServerURL, "master", options.APIServerURL, "The API server's URL.")
97 97
 	flags.StringSliceVar(&options.APIServerCAFiles, "certificate-authority", options.APIServerCAFiles, "Files containing signing authorities to use to verify the API server's serving certificate.")
98
-	flags.StringVar(&options.NetworkPluginName, "network-plugin", options.NetworkPluginName, "Name of the network plugin to hook to for pod networking. Optional for OpenShift network plugin, node will auto detect network plugin configured by OpenShift master.")
98
+	flags.StringVar(&options.NetworkPluginName, "network-plugin", options.NetworkPluginName, "Name of the network plugin to hook to for pod networking.")
99 99
 
100 100
 	// autocompletion hints
101 101
 	cmd.MarkFlagFilename("node-dir")
... ...
@@ -174,7 +174,6 @@ type LocalQuota struct {
174 174
 // NodeNetworkConfig provides network options for the node
175 175
 type NodeNetworkConfig struct {
176 176
 	// NetworkPluginName is a string specifying the networking plugin
177
-	// Optional for OpenShift network plugin, node will auto detect network plugin configured by OpenShift master.
178 177
 	NetworkPluginName string
179 178
 	// Maximum transmission unit for the network packets
180 179
 	MTU uint32
... ...
@@ -120,8 +120,7 @@ type NodeAuthConfig struct {
120 120
 // NodeNetworkConfig provides network options for the node
121 121
 type NodeNetworkConfig struct {
122 122
 	// NetworkPluginName is a string specifying the networking plugin
123
-	// Optional for OpenShift network plugin, node will auto detect network plugin configured by OpenShift master.
124
-	NetworkPluginName string `json:"networkPluginName,omitempty"`
123
+	NetworkPluginName string `json:"networkPluginName"`
125 124
 	// Maximum transmission unit for the network packets
126 125
 	MTU uint32 `json:"mtu"`
127 126
 }
... ...
@@ -45,6 +45,7 @@ masterClientConnectionOverrides: null
45 45
 masterKubeConfig: ""
46 46
 networkConfig:
47 47
   mtu: 0
48
+  networkPluginName: ""
48 49
 nodeIP: ""
49 50
 nodeName: ""
50 51
 podManifestConfig:
... ...
@@ -135,8 +135,7 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig, enableProxy, enable
135 135
 		return nil, fmt.Errorf("cannot parse node port: %v", err)
136 136
 	}
137 137
 
138
-	options.NetworkConfig.NetworkPluginName, err = validateAndGetNetworkPluginName(originClient, options.NetworkConfig.NetworkPluginName)
139
-	if err != nil {
138
+	if err = validateNetworkPluginName(originClient, options.NetworkConfig.NetworkPluginName); err != nil {
140 139
 		return nil, err
141 140
 	}
142 141
 
... ...
@@ -419,31 +418,24 @@ func buildKubeProxyConfig(options configapi.NodeConfig) (*proxyoptions.ProxyServ
419 419
 	return proxyconfig, nil
420 420
 }
421 421
 
422
-func validateAndGetNetworkPluginName(originClient *osclient.Client, pluginName string) (string, error) {
422
+func validateNetworkPluginName(originClient *osclient.Client, pluginName string) error {
423 423
 	if sdnplugin.IsOpenShiftNetworkPlugin(pluginName) {
424 424
 		// Detect any plugin mismatches between node and master
425 425
 		clusterNetwork, err := originClient.ClusterNetwork().Get(sdnapi.ClusterNetworkDefault)
426 426
 		if kerrs.IsNotFound(err) {
427
-			return "", fmt.Errorf("master has not created a default cluster network, network plugin %q can not start", pluginName)
427
+			return fmt.Errorf("master has not created a default cluster network, network plugin %q can not start", pluginName)
428 428
 		} else if err != nil {
429
-			return "", fmt.Errorf("cannot fetch %q cluster network: %v", sdnapi.ClusterNetworkDefault, err)
429
+			return fmt.Errorf("cannot fetch %q cluster network: %v", sdnapi.ClusterNetworkDefault, err)
430 430
 		}
431 431
 
432 432
 		if clusterNetwork.PluginName != strings.ToLower(pluginName) {
433 433
 			if len(clusterNetwork.PluginName) != 0 {
434
-				return "", fmt.Errorf("detected network plugin mismatch between OpenShift node(%q) and master(%q)", pluginName, clusterNetwork.PluginName)
434
+				return fmt.Errorf("detected network plugin mismatch between OpenShift node(%q) and master(%q)", pluginName, clusterNetwork.PluginName)
435 435
 			} else {
436 436
 				// Do not return error in this case
437 437
 				glog.Warningf(`either there is network plugin mismatch between OpenShift node(%q) and master or OpenShift master is running an older version where we did not persist plugin name`, pluginName)
438 438
 			}
439 439
 		}
440
-	} else if pluginName == "" {
441
-		// Auto detect network plugin configured by master
442
-		clusterNetwork, err := originClient.ClusterNetwork().Get(sdnapi.ClusterNetworkDefault)
443
-		if err == nil {
444
-			return clusterNetwork.PluginName, nil
445
-		}
446 440
 	}
447
-
448
-	return pluginName, nil
441
+	return nil
449 442
 }
... ...
@@ -80,7 +80,7 @@ func BindNodeArgs(args *NodeArgs, flags *pflag.FlagSet, prefix string, component
80 80
 		args.Components.Bind(flags, prefix+"%s", "The set of node components to")
81 81
 	}
82 82
 
83
-	flags.StringVar(&args.NetworkPluginName, prefix+"network-plugin", args.NetworkPluginName, "The network plugin to be called for configuring networking for pods. Optional for OpenShift network plugin, node will auto detect network plugin configured by OpenShift master.")
83
+	flags.StringVar(&args.NetworkPluginName, prefix+"network-plugin", args.NetworkPluginName, "The network plugin to be called for configuring networking for pods.")
84 84
 
85 85
 	flags.StringVar(&args.VolumeDir, prefix+"volume-dir", "openshift.local.volumes", "The volume storage directory.")
86 86
 	// TODO rename this node-name and recommend uname -n
... ...
@@ -97,7 +97,7 @@ func BindNodeArgs(args *NodeArgs, flags *pflag.FlagSet, prefix string, component
97 97
 func BindNodeNetworkArgs(args *NodeArgs, flags *pflag.FlagSet, prefix string) {
98 98
 	args.Components.Bind(flags, "%s", "The set of network components to")
99 99
 
100
-	flags.StringVar(&args.NetworkPluginName, prefix+"network-plugin", args.NetworkPluginName, "The network plugin to be called for configuring networking for pods. Optional for OpenShift network plugin, node will auto detect network plugin configured by OpenShift master.")
100
+	flags.StringVar(&args.NetworkPluginName, prefix+"network-plugin", args.NetworkPluginName, "The network plugin to be called for configuring networking for pods.")
101 101
 }
102 102
 
103 103
 // NewDefaultNodeArgs creates NodeArgs with sub-objects created and default values set.
... ...
@@ -286,8 +286,6 @@ func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentF
286 286
 		return err
287 287
 	}
288 288
 
289
-	// In case of openshift network plugin, nodeConfig.networkPluginName is optional and is auto detected/finalized
290
-	// once we build kubernetes node config. So perform plugin name related check here.
291 289
 	if sdnplugin.IsOpenShiftNetworkPlugin(config.KubeletServer.NetworkPluginName) {
292 290
 		// TODO: SDN plugin depends on the Kubelet registering as a Node and doesn't retry cleanly,
293 291
 		// and Kubelet also can't start the PodSync loop until the SDN plugin has loaded.