diff --git a/node/cmd/calico-node/main.go b/node/cmd/calico-node/main.go index eef9a1a1213..cac6db7ee85 100644 --- a/node/cmd/calico-node/main.go +++ b/node/cmd/calico-node/main.go @@ -53,6 +53,7 @@ var monitorAddrs = flagSet.Bool("monitor-addresses", false, "Monitor change in n var runAllocateTunnelAddrs = flagSet.Bool("allocate-tunnel-addrs", false, "Configure tunnel addresses for this node") var allocateTunnelAddrsRunOnce = flagSet.Bool("allocate-tunnel-addrs-run-once", false, "Run allocate-tunnel-addrs in oneshot mode") var monitorToken = flagSet.Bool("monitor-token", false, "Watch for Kubernetes token changes, update CNI config") +var setNodeNetworkUnavailable = flagSet.Bool("set-node-network-unavailable", true, "Set nodeNetworkUnavailable after calico startup") // Options for liveness checks. var felixLive = flagSet.Bool("felix-live", false, "Run felix liveness checks") @@ -135,7 +136,7 @@ func main() { nodeinit.Run(*bestEffort) } else if *runStartup { logrus.SetFormatter(&logutils.Formatter{Component: "startup"}) - startup.Run() + startup.Run(*setNodeNetworkUnavailable) } else if *runShutdown { logrus.SetFormatter(&logutils.Formatter{Component: "shutdown"}) shutdown.Run() diff --git a/node/pkg/lifecycle/startup/startup.go b/node/pkg/lifecycle/startup/startup.go index 4deb875fc0a..5ec55135dfd 100644 --- a/node/pkg/lifecycle/startup/startup.go +++ b/node/pkg/lifecycle/startup/startup.go @@ -84,7 +84,7 @@ var ( // - Configuring the node resource with IP/AS information provided in the // environment, or autodetected. // - Creating default IP Pools for quick-start use -func Run() { +func Run(setNodeNetworkUnavailable bool) { // Check $CALICO_STARTUP_LOGLEVEL to capture early log statements ConfigureLogging() @@ -222,10 +222,12 @@ func Run() { // node condition will trigger node-controller updating node taints. if os.Getenv("CALICO_NETWORKING_BACKEND") != "none" { if clientset != nil { - err := utils.SetNodeNetworkUnavailableCondition(*clientset, k8sNodeName, false, 30*time.Second) - if err != nil { - log.WithError(err).Error("Unable to set NetworkUnavailable to False") - utils.Terminate() + if setNodeNetworkUnavailable { + err := utils.SetNodeNetworkUnavailableCondition(*clientset, k8sNodeName, false, 30*time.Second) + if err != nil { + log.WithError(err).Error("Unable to set NetworkUnavailable to False") + utils.Terminate() + } } } }