diff --git a/controller/instance_manager_controller.go b/controller/instance_manager_controller.go index de52d0dc5d..dcebbae016 100644 --- a/controller/instance_manager_controller.go +++ b/controller/instance_manager_controller.go @@ -534,7 +534,7 @@ func (imc *InstanceManagerController) areDangerZoneSettingsSyncedToIMPod(im *lon } } - pod, err := imc.ds.GetPod(im.Name) + pod, err := imc.ds.GetPodRO(im.Namespace, im.Name) if err != nil { return false, false, false, errors.Wrapf(err, "cannot get pod for instance manager %v", im.Name) } @@ -622,8 +622,8 @@ func (imc *InstanceManagerController) isSettingPriorityClassSynced(setting *long func (imc *InstanceManagerController) isSettingStorageNetworkSynced(setting *longhorn.Setting, pod *corev1.Pod) (bool, error) { nadAnnot := string(types.CNIAnnotationNetworks) - - return pod.Annotations[nadAnnot] == setting.Value, nil + nadAnnotValue := types.CreateCniAnnotationFromSetting(setting) + return pod.Annotations[nadAnnot] == nadAnnotValue, nil } func (imc *InstanceManagerController) isSettingDataEngineSynced(settingName types.SettingName, im *longhorn.InstanceManager) (bool, error) { diff --git a/controller/setting_controller.go b/controller/setting_controller.go index 0bb811db02..60a4470238 100644 --- a/controller/setting_controller.go +++ b/controller/setting_controller.go @@ -820,6 +820,8 @@ func (sc *SettingController) updateCNI() error { } nadAnnot := string(types.CNIAnnotationNetworks) + nadAnnotValue := types.CreateCniAnnotationFromSetting(storageNetwork) + imPodList, err := sc.ds.ListInstanceManagerPods() if err != nil { return errors.Wrapf(err, "failed to list instance manager Pods for %v setting update", types.SettingNameStorageNetwork) @@ -832,10 +834,16 @@ func (sc *SettingController) updateCNI() error { pods := append(imPodList, bimPodList...) for _, pod := range pods { - if pod.Annotations[nadAnnot] == storageNetwork.Value { + if pod.Annotations[nadAnnot] == nadAnnotValue { continue } + logrus.WithFields(logrus.Fields{ + "pod": pod.Name, + "oldValue": pod.Annotations[nadAnnot], + "newValue": nadAnnotValue, + }).Infof("Deleting pod to update the %v annotation", nadAnnot) + if err := sc.ds.DeletePod(pod.Name); err != nil { return err }