diff --git a/pkg/routeagent_driver/main.go b/pkg/routeagent_driver/main.go index fb2b41be8..08300099e 100644 --- a/pkg/routeagent_driver/main.go +++ b/pkg/routeagent_driver/main.go @@ -54,7 +54,6 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/clientcmd" - nodeutil "k8s.io/component-helpers/node/util" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager/signals" ) @@ -82,7 +81,7 @@ func main() { logger.Info("Starting submariner-route-agent using the event framework") // set up signals so we handle the first shutdown signal gracefully - stopCh := signals.SetupSignalHandler().Done() + ctx := signals.SetupSignalHandler() // Clean up "sockets" created as directories by previous versions removeInvalidSockets() @@ -111,7 +110,7 @@ func main() { logger.FatalOnError(err, "Error building the REST mapper") if env.WaitForNode { - waitForNodeReady(k8sClientSet) + node.WaitForLocalNodeReady(ctx, k8sClientSet) return } @@ -163,6 +162,8 @@ func main() { }) logger.FatalOnError(err, "Error creating controller for event handling") + stopCh := ctx.Done() + err = ctl.Start(stopCh) logger.FatalOnError(err, "Error starting controller") @@ -211,27 +212,6 @@ func uninstall(registry *event.Registry) { } } -func waitForNodeReady(k8sClientSet *kubernetes.Clientset) { - // In most cases the node will already be ready; otherwise, wait for ever - for { - localNode, err := node.GetLocalNode(k8sClientSet) - - if err != nil { - logger.Error(err, "Error retrieving local node") - } else if localNode != nil { - _, condition := nodeutil.GetNodeCondition(&localNode.Status, corev1.NodeReady) - if condition != nil && condition.Status == corev1.ConditionTrue { - logger.Info("Node ready") - return - } - - logger.Infof("Node not ready, waiting: %v", localNode.Status) - } - - time.Sleep(1 * time.Second) - } -} - func removeInvalidSockets() { // This can be removed once we stop supporting upgrades from 0.16.0 or older for _, dir := range []string{"/run/openvswitch/db.sock", "/var/run/openvswitch/ovnnb_db.sock", "/var/run/ovn-ic/ovnnb_db.sock"} {