From aee0c190fd724e5301d89cb7cc7684edb19a7d8b Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Fri, 20 Sep 2024 15:32:01 +0800 Subject: [PATCH] feat(v2/auto-salvage): block trim op when volume is degraded longhorn/longhorn-8430 Signed-off-by: Chin-Ya Huang --- manager/volume.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manager/volume.go b/manager/volume.go index 97b65dce0c..df6ab76adf 100644 --- a/manager/volume.go +++ b/manager/volume.go @@ -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) }