Remote vteps to be populated even when CNIIface is missing
During some recent refactoring, it looks like the code that updates
the remoteVteps is moved under cniIface validation. This PR fixes it.
@@ -227,26 +227,17 @@ func (r *Controller) Run(stopCh <-chan struct{}) error {
}
if r.cniIface != nil {
- err = r.annotateThisNodeWithCNInterfaceIP()
+ hostname, err := os.Hostname()
if err != nil {
- return err
- }
- } else {
- klog.Warning("cniInterface wasn't found, hostNetwork to remote pod/service connectivity won't work")
+ klog.Fatalf("unable to determine hostname: %v", err)
}
- go wait.Until(r.runEndpointWorker, time.Second, stopCh)
- go wait.Until(r.runPodWorker, time.Second, stopCh)
- klog.Info("Route agent workers started")
- <-stopCh
- klog.Info("Route agent stopping")
- return nil
+ // Each route-agent pod will annotate its own node with the respective CNIInterfaceIP
+ if err = r.annotateNodeWithCNIInterfaceIP(hostname); err != nil {
+ return fmt.Errorf("error annotating the node %q with cniIfaceIP: %v", hostname, err)
}
-
-func (r *Controller) annotateThisNodeWithCNInterfaceIP() error {
- hostname, err := os.Hostname()
- if err != nil {
- klog.Fatalf("unable to determine hostname: %v", err)
+ } else {
+ klog.Warning("cniInterface wasn't found, hostNetwork to remote pod/service connectivity won't work")
}
// Query all the submariner-route-agent daemonSet PODs running in the local cluster.
@@ -258,13 +249,13 @@ func (r *Controller) annotateThisNodeWithCNInterfaceIP() error {
for index, pod := range podList.Items {
klog.V(log.DEBUG).Infof("In %s, podIP of submariner-route-agent[%d] is %s", r.clusterID, index, pod.Status.PodIP)
r.populateRemoteVtepIps(pod.Status.PodIP)
- // Each route-agent pod will annotate its own node with the respective CNIInterfaceIP
- if hostname == pod.Spec.NodeName {
- if err = r.annotateNodeWithCNIInterfaceIP(pod.Spec.NodeName); err != nil {
- return fmt.Errorf("error annotating the node %q with cniIfaceIP: %v", hostname, err)
- }
- }
}
+
+ go wait.Until(r.runEndpointWorker, time.Second, stopCh)
+ go wait.Until(r.runPodWorker, time.Second, stopCh)
+ klog.Info("Route agent workers started")
+ <-stopCh
+ klog.Info("Route agent stopping")
return nil
}
