controller: Add log for replica failure
@@ -492,6 +492,8 @@ func (vc *VolumeController) ReconcileEngineReplicaState(v *longhorn.Volume, es m
return nil
}
+ log := getLoggerForVolume(vc.logger, v).WithField("currentEngine", e.Name)
+
if e.Status.CurrentState == longhorn.InstanceStateUnknown {
if v.Status.Robustness != longhorn.VolumeRobustnessUnknown {
v.Status.Robustness = longhorn.VolumeRobustnessUnknown
@@ -549,6 +551,7 @@ func (vc *VolumeController) ReconcileEngineReplicaState(v *longhorn.Volume, es m
vc.eventRecorder.Eventf(v, v1.EventTypeWarning, EventReasonFailedSnapshotPurge, "replica %v failed the snapshot purge: %s", r.Name, purgeStatus.Error)
}
if r.Spec.FailedAt == "" {
+ log.Warnf("Replica %v is marked as failed, current state %v, mode %v, engine name %v, active %v", r.Name, r.Status.CurrentState, mode, r.Spec.EngineName, r.Spec.Active)
r.Spec.FailedAt = vc.nowHandler()
e.Spec.LogRequested = true
r.Spec.LogRequested = true
@@ -566,10 +569,11 @@ func (vc *VolumeController) ReconcileEngineReplicaState(v *longhorn.Volume, es m
healthyCount++
}
}
- // If a replica failed at attaching stage,
+ // If a replica failed at attaching/migrating stage,
// there is no record in e.Status.ReplicaModeMap
for _, r := range rs {
if r.Spec.FailedAt == "" && r.Status.CurrentState == longhorn.InstanceStateError {
+ log.Warnf("Replica %v that not in the engine mode map is marked as failed, current state %v, engine name %v, active %v", r.Name, r.Status.CurrentState, r.Spec.EngineName, r.Spec.Active)
e.Spec.LogRequested = true
r.Spec.LogRequested = true
r.Spec.FailedAt = vc.nowHandler()
