controller: Cleanup instanceManagerName after printing the instance log
@@ -144,9 +144,9 @@ func (h *InstanceHandler) syncStatusWithInstanceManager(im *longhorn.InstanceMan
status.Port = 0
default:
logrus.Warnf("instance %v state is %v, error message %v", instanceName, instance.Status.State, instance.Status.ErrorMsg)
+ // cannot cleanup InstanceManagerName here, since we need it to print the log.
status.CurrentState = types.InstanceStateError
status.CurrentImage = ""
- status.InstanceManagerName = ""
status.IP = ""
status.Port = 0
// Don't reset status.NodeBootID, we need it to identify a node reboot
@@ -251,7 +251,8 @@ func (h *InstanceHandler) ReconcileInstanceState(obj interface{}, spec *types.In
return err
}
}
- } else if status.CurrentState == types.InstanceStateError && im != nil {
+ } else if status.CurrentState == types.InstanceStateError {
+ if im != nil {
if _, exists := im.Status.Instances[instanceName]; exists {
logrus.Warnf("Instance %v crashed on Instance Manager %v at %v, try to get log", instanceName, im.Name, im.Spec.NodeID)
if err := h.printInstanceLogs(instanceName, runtimeObj); err != nil {
@@ -259,6 +260,8 @@ func (h *InstanceHandler) ReconcileInstanceState(obj interface{}, spec *types.In
}
}
}
+ status.InstanceManagerName = ""
+ }
return nil
}
