Skip to content

Commit

Permalink
fix(storage-network): annotated pod in creation loop
Browse files Browse the repository at this point in the history
longhorn-7640

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
(cherry picked from commit 43e997c)
  • Loading branch information
c3y1huang authored and mergify[bot] committed Apr 4, 2024
1 parent f770fa8 commit 50ec157
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions controller/instance_manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,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) {
Expand Down
10 changes: 9 additions & 1 deletion controller/setting_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,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)
Expand All @@ -775,10 +777,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
}
Expand Down

0 comments on commit 50ec157

Please sign in to comment.