Skip to content

Commit 769fb2b

Browse files
committed
fix: add logs for instance manager state error update
Signed-off-by: Shuo Wu <shuo.wu@suse.com>
1 parent 596d573 commit 769fb2b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

controller/instance_manager_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,14 @@ func (imc *InstanceManagerController) syncStatusWithPod(im *longhorn.InstanceMan
460460
im.Status.CurrentState = longhorn.InstanceManagerStateStopped
461461
return nil
462462
}
463+
imc.logger.Warnf("Instance manager pod %v is not found, updating the instance manager state from %s to error", im.Name, im.Status.CurrentState)
463464
im.Status.CurrentState = longhorn.InstanceManagerStateError
464465
return nil
465466
}
466467

467468
// By design instance manager pods should not be terminated.
468469
if pod.DeletionTimestamp != nil {
470+
imc.logger.Warnf("Instance manager pod %v is being deleted, updating the instance manager state from %s to error", im.Name, im.Status.CurrentState)
469471
im.Status.CurrentState = longhorn.InstanceManagerStateError
470472
return nil
471473
}
@@ -488,6 +490,7 @@ func (imc *InstanceManagerController) syncStatusWithPod(im *longhorn.InstanceMan
488490
im.Status.CurrentState = longhorn.InstanceManagerStateStarting
489491
}
490492
default:
493+
imc.logger.Warnf("Instance manager pod %v is in phase %s, updating the instance manager state from %s to error", im.Name, pod.Status.Phase, im.Status.CurrentState)
491494
im.Status.CurrentState = longhorn.InstanceManagerStateError
492495
}
493496

@@ -697,6 +700,7 @@ func (imc *InstanceManagerController) annotateCASafeToEvict(im *longhorn.Instanc
697700

698701
func (imc *InstanceManagerController) areDangerZoneSettingsSyncedToIMPod(im *longhorn.InstanceManager) (isSynced, isPodDeletedOrNotRunning, areInstancesRunningInPod bool, err error) {
699702
if im.Status.CurrentState != longhorn.InstanceManagerStateRunning {
703+
imc.logger.Infof("Instance manager %v is state %s rather than running hence the setting is considered as not synced while the pod is considered as not running", im.Name, im.Status.CurrentState)
700704
return false, true, false, nil
701705
}
702706

@@ -712,6 +716,7 @@ func (imc *InstanceManagerController) areDangerZoneSettingsSyncedToIMPod(im *lon
712716
return false, false, false, errors.Wrapf(err, "cannot get pod for instance manager %v", im.Name)
713717
}
714718
if pod == nil {
719+
imc.logger.Infof("Pod for instance manager %v is nil hence the setting is considered as not synced while the pod is considered as not running", im.Name)
715720
return false, true, false, nil
716721
}
717722

0 commit comments

Comments
 (0)