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>
  • Loading branch information
c3y1huang authored and innobead committed Jan 12, 2024
1 parent 6c305ae commit 43e997c
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 @@ -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) {
Expand Down
10 changes: 9 additions & 1 deletion controller/setting_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit 43e997c

Please sign in to comment.