From 29df40f89c038316c19dd26bc7cca645595524a0 Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Thu, 19 Sep 2024 16:37:18 +0800 Subject: [PATCH 1/5] chore: update vendors longhorn/longhorn-8430 Signed-off-by: Chin-Ya Huang --- go.mod | 2 +- go.sum | 4 ++-- .../longhorn/longhorn-instance-manager/pkg/client/instance.go | 2 ++ vendor/modules.txt | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 421e2caac1..062ece2e79 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,7 @@ require ( github.com/longhorn/go-iscsi-helper v0.0.0-20241103035054-568634165efd github.com/longhorn/go-spdk-helper v0.0.0-20241103044742-606c0ee8d532 github.com/longhorn/longhorn-engine v1.8.0-dev-20241103 - github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103 + github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103.0.20241106043114-e5808281c3a5 github.com/longhorn/longhorn-share-manager v1.7.0-rc1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.20.5 diff --git a/go.sum b/go.sum index b1598df6b4..7bef48da86 100644 --- a/go.sum +++ b/go.sum @@ -170,8 +170,8 @@ github.com/longhorn/go-spdk-helper v0.0.0-20241103044742-606c0ee8d532 h1:hAPa1Uc github.com/longhorn/go-spdk-helper v0.0.0-20241103044742-606c0ee8d532/go.mod h1:hMcAO/kxvkAjW/nL7mYsNonJUQhFSh0rMMQ/A/PjTLI= github.com/longhorn/longhorn-engine v1.8.0-dev-20241103 h1:Q3RKmiD9SlxJ9bMRA+Rs0gbEFzQek2zkOjkbnuVpcPQ= github.com/longhorn/longhorn-engine v1.8.0-dev-20241103/go.mod h1:7c7M3uig+IpM252ewuQ3VZIRIWtwuLOOTBmvLm61QZw= -github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103 h1:Q2NlViVKqFNudHA51AW+vOJvg5jR3cLwJ8W6Ax3mKGo= -github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103/go.mod h1:AsT/MU1GLf6E+KMfJQywIcauCJQdcVt9a/PH5D/FSVw= +github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103.0.20241106043114-e5808281c3a5 h1:YzoHpa8BGPIG7VY+ogv04fs3SrFuVOWEOuU20KmsCfM= +github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103.0.20241106043114-e5808281c3a5/go.mod h1:bFWa3cQwt7eO1M/g+PiDDSlIcnmhDIT3DaZPZEiCmKE= github.com/longhorn/longhorn-share-manager v1.7.0-rc1 h1:LsSkSajhG8tCfORKKfwK+8XHVrT/8rI9DRWb7fuoVls= github.com/longhorn/longhorn-share-manager v1.7.0-rc1/go.mod h1:R6+NscPU4lAV5ueO7//lBCAO3en0aDbZi5KkkOSUJvk= github.com/longhorn/types v0.0.0-20241101010532-9e901229a935 h1:s6ngry7kCUdggXRKywHdwt98vjbOZQX8Txq166hxph0= diff --git a/vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go b/vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go index 6b4f67083f..c2f862385c 100644 --- a/vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go +++ b/vendor/github.com/longhorn/longhorn-instance-manager/pkg/client/instance.go @@ -91,6 +91,7 @@ type EngineCreateRequest struct { InitiatorAddress string TargetAddress string UpgradeRequired bool + SalvageRequested bool } type ReplicaCreateRequest struct { @@ -147,6 +148,7 @@ func (c *InstanceServiceClient) InstanceCreate(req *InstanceCreateRequest) (*api Size: req.Size, ReplicaAddressMap: req.Engine.ReplicaAddressMap, Frontend: req.Engine.Frontend, + SalvageRequested: req.Engine.SalvageRequested, } case types.InstanceTypeReplica: spdkInstanceSpec = &rpc.SpdkInstanceSpec{ diff --git a/vendor/modules.txt b/vendor/modules.txt index caa02330ec..bac53a673b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -278,7 +278,7 @@ github.com/longhorn/longhorn-engine/pkg/meta github.com/longhorn/longhorn-engine/pkg/replica/client github.com/longhorn/longhorn-engine/pkg/types github.com/longhorn/longhorn-engine/pkg/util -# github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103 +# github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20241103.0.20241106043114-e5808281c3a5 ## explicit; go 1.22.2 github.com/longhorn/longhorn-instance-manager/pkg/api github.com/longhorn/longhorn-instance-manager/pkg/client From ba748da54fdb3ddfdefb1ef10779d80d951cf90e Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Mon, 23 Sep 2024 15:43:29 +0800 Subject: [PATCH 2/5] feat(v2/auto-salvage): identify engine instance replica needs salvage longhorn/longhorn-8430 Signed-off-by: Chin-Ya Huang --- engineapi/instance_manager.go | 1 + 1 file changed, 1 insertion(+) diff --git a/engineapi/instance_manager.go b/engineapi/instance_manager.go index 899c078f5f..3f7d00a67c 100644 --- a/engineapi/instance_manager.go +++ b/engineapi/instance_manager.go @@ -513,6 +513,7 @@ func (c *InstanceManagerClient) EngineInstanceCreate(req *EngineInstanceCreateRe UpgradeRequired: req.UpgradeRequired, InitiatorAddress: req.InitiatorAddress, TargetAddress: req.TargetAddress, + SalvageRequested: req.Engine.Spec.SalvageRequested, }, }) From bb0fb4b0f14a33a0d9f315142b3cda92f3bb4780 Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Thu, 5 Sep 2024 12:17:31 +0800 Subject: [PATCH 3/5] feat(v2/auto-salvage): remove blocking for v2 volumes longhorn/longhorn-8430 Signed-off-by: Chin-Ya Huang --- controller/volume_controller.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/controller/volume_controller.go b/controller/volume_controller.go index e40b3dbed2..c25e2674ae 100644 --- a/controller/volume_controller.go +++ b/controller/volume_controller.go @@ -1333,11 +1333,8 @@ func (c *VolumeController) ReconcileVolumeState(v *longhorn.Volume, es map[strin // At this moment, Longhorn goes into the IF statement below this IF statement and salvage all replicas. if autoSalvage && !v.Status.IsStandby && !v.Status.RestoreRequired { // Since all replica failed and autoSalvage is enable, mark engine controller salvage requested - // TODO: SalvageRequested is meanningless for v2 volume - if types.IsDataEngineV1(v.Spec.DataEngine) { - e.Spec.SalvageRequested = true - log.Infof("All replicas are failed, set engine salvageRequested to %v", e.Spec.SalvageRequested) - } + e.Spec.SalvageRequested = true + log.Infof("All replicas are failed, set engine salvageRequested to %v", e.Spec.SalvageRequested) } // make sure the volume is detached before automatically salvage replicas if autoSalvage && v.Status.State == longhorn.VolumeStateDetached && !v.Status.IsStandby && !v.Status.RestoreRequired { From 5de117aa6af2ef2e05569e634c1fe25865014a39 Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Fri, 20 Sep 2024 15:32:01 +0800 Subject: [PATCH 4/5] 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) } From 3d806c6dffcebdf321dced7cb2b8e9cdab10bc5b Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Thu, 24 Oct 2024 17:30:25 +0800 Subject: [PATCH 5/5] chore: enhance logging Signed-off-by: Chin-Ya Huang --- controller/volume_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/volume_controller.go b/controller/volume_controller.go index c25e2674ae..5e32ae1d31 100644 --- a/controller/volume_controller.go +++ b/controller/volume_controller.go @@ -1388,7 +1388,7 @@ func (c *VolumeController) ReconcileVolumeState(v *longhorn.Volume, es map[strin if !dataExists { log.Warn("Failed to auto salvage volume: no data exists") } else { - log.Info("Bringing up replicas for auto-salvage") + log.Infof("Bringing up %v replicas for auto-salvage", len(failedUsableReplicas)) // This salvage is for revision counter enabled case salvaged := false