Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auto-salvage): v2 support #3170

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
c3y1huang marked this conversation as resolved.
Show resolved Hide resolved
}
// make sure the volume is detached before automatically salvage replicas
if autoSalvage && v.Status.State == longhorn.VolumeStateDetached && !v.Status.IsStandby && !v.Status.RestoreRequired {
Expand Down Expand Up @@ -1391,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
Expand Down
1 change: 1 addition & 0 deletions engineapi/instance_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ func (c *InstanceManagerClient) EngineInstanceCreate(req *EngineInstanceCreateRe
UpgradeRequired: req.UpgradeRequired,
InitiatorAddress: req.InitiatorAddress,
TargetAddress: req.TargetAddress,
SalvageRequested: req.Engine.Spec.SalvageRequested,
},
})

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down