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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 2 additions & 5 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)
}
// 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
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
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ replace (
k8s.io/sample-controller => k8s.io/sample-controller v0.31.1
)

replace github.com/longhorn/longhorn-instance-manager => github.com/c3y1huang/longhorn-instance-manager v1.8.0-dev-20240908.0.20240927080458-479e2769617e

replace github.com/longhorn/types => github.com/c3y1huang/types v0.0.0-20240927050527-1fc6fe5fa4f9

require (
github.com/container-storage-interface/spec v1.10.0
github.com/docker/go-connections v0.5.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/c3y1huang/longhorn-instance-manager v1.8.0-dev-20240908.0.20240927080458-479e2769617e h1:qUEoqqWkvHkyPsY602QsD2+nv27MW8AiPec3CkY2xKo=
github.com/c3y1huang/longhorn-instance-manager v1.8.0-dev-20240908.0.20240927080458-479e2769617e/go.mod h1:TGe5d/pzErPXtfMa0r3jcoct+B+YZ+DO3xxCuIK9osI=
github.com/c3y1huang/types v0.0.0-20240927050527-1fc6fe5fa4f9 h1:Jh88TpuLXQELSFtpwEwv8yZgcHE3VurY/flB2V8fIHo=
github.com/c3y1huang/types v0.0.0-20240927050527-1fc6fe5fa4f9/go.mod h1:KlJuZB8NfHchWshYxYgV9pPIxBKC04Vq05G2TfgMf7w=
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8 h1:SjZ2GvvOononHOpK84APFuMvxqsk3tEIaKH/z4Rpu3g=
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8/go.mod h1:uEyr4WpAH4hio6LFriaPkL938XnrvLpNPmQHBdrmbIE=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
Expand Down Expand Up @@ -169,12 +173,8 @@ github.com/longhorn/go-spdk-helper v0.0.0-20240922062342-22115a91cbe9 h1:DVYw6dz
github.com/longhorn/go-spdk-helper v0.0.0-20240922062342-22115a91cbe9/go.mod h1:pKbJjuJN69T+qDaJIkR1NcpGqCzj/vGv1NTTDiaE5s0=
github.com/longhorn/longhorn-engine v1.8.0-dev-20240922 h1:sV9UfurVeEuWx0jaNndtvBJnOR6ZYmrJU3f7pObfLhA=
github.com/longhorn/longhorn-engine v1.8.0-dev-20240922/go.mod h1:d5+LbCuwivslvz0Qp0drZ5vyuT+s1NR+v9clerORT58=
github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20240922 h1:1D+xZxI4mz69KugQszz58jzoXsnO9w5+0cIsfgIKJog=
github.com/longhorn/longhorn-instance-manager v1.8.0-dev-20240922/go.mod h1:2FqfvyoXCiRGoHyCGukBn0UxOm21w73oswGNcoae9c4=
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-20240902072916-1bf23d310acb h1:8CoW5YYn+SC43o5zFR+wscOd3SgF6rQZjrkXOkJfZPM=
github.com/longhorn/types v0.0.0-20240902072916-1bf23d310acb/go.mod h1:KlJuZB8NfHchWshYxYgV9pPIxBKC04Vq05G2TfgMf7w=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
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.

Loading