controller: Reconcile volume to faulted state when all replicas have failed
longhorn issue
@@ -383,6 +383,24 @@ func (vc *VolumeController) ReconcileEngineReplicaState(v *longhorn.Volume, e *l
}
if e.Status.CurrentState != types.InstanceStateRunning {
+ // Corner case: when vc found healthyCount is 0, vc failed to update volume to faulted state
+ // and volume may be detached (engine stopped state).
+ // Then the volume needs to be reconciled to the faulted state here.
+ availableCount := 0
+ for _, r := range rs {
+ if r.Spec.FailedAt == "" {
+ availableCount++
+ }
+ }
+ if availableCount == 0 {
+ oldRobustness := v.Status.Robustness
+ v.Status.Robustness = types.VolumeRobustnessFaulted
+ if oldRobustness != types.VolumeRobustnessFaulted {
+ vc.eventRecorder.Eventf(v, v1.EventTypeWarning, EventReasonFaulted, "volume %v became faulted", v.Name)
+ }
+ // detach the volume
+ v.Spec.NodeID = ""
+ }
return nil
}
