Skip to content

Commit

Permalink
feat(v2/auto-salvage): block trim op when volume is degraded
Browse files Browse the repository at this point in the history
longhorn/longhorn-8430

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang committed Sep 23, 2024
1 parent cf49593 commit 66f7725
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions manager/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ func (m *VolumeManager) TrimFilesystem(name string) (v *longhorn.Volume, err err
return nil, fmt.Errorf("volume frontend is disabled")
}

// Blocks degraded v2 volume from being trimmed to maintain reliable volume
// head size for failed usable replica candidate selection.
if types.IsDataEngineV2(v.Spec.DataEngine) {
if v.Status.Robustness == longhorn.VolumeRobustnessDegraded {
return nil, fmt.Errorf("volume is degraded")
}
}

if v.Spec.AccessMode == longhorn.AccessModeReadWriteMany {
return v, m.trimRWXVolumeFilesystem(name, v.Spec.Encrypted)
}
Expand Down

0 comments on commit 66f7725

Please sign in to comment.