Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setNodeNetworkUnavailable option for calico node #9479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion node/cmd/calico-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 7 additions & 5 deletions node/pkg/lifecycle/startup/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
}
}
}
}
Expand Down