Skip to content

Commit

Permalink
feat(v2/auto-salvage): failed usable replica candidate selection
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 19, 2024
1 parent 28f3714 commit 411fa62
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,11 @@ func (c *VolumeController) ReconcileVolumeState(v *longhorn.Volume, es map[strin
failedUsableReplicas := map[string]*longhorn.Replica{}
dataExists := false

snapshots, err := c.ds.ListVolumeSnapshotsRO(v.Name)
if err != nil {
return err
}

for _, r := range rs {
if r.Spec.HealthyAt == "" {
continue
Expand Down Expand Up @@ -1377,6 +1382,22 @@ func (c *VolumeController) ReconcileVolumeState(v *longhorn.Volume, es map[strin
if !diskSchedulable {
continue
}

isReplicaHasAllSnapshots := true
// The v1 volume candidate selection will be handled in the engine instance.
if types.IsDataEngineV2(v.Spec.DataEngine) {
for snapshotName := range snapshots {
if _, exist := r.Status.Snapshots[snapshotName]; !exist {
isReplicaHasAllSnapshots = false
continue
}
}
}
if !isReplicaHasAllSnapshots {
log.WithField("replica", r.Name).Debug("Cannot reuse failed replica because it does not contain all snapshots")
continue
}

failedAt, err := util.ParseTime(r.Spec.FailedAt)
if err != nil {
log.WithField("replica", r.Name).WithError(err).Warn("Failed to parse FailedAt timestamp for replica")
Expand Down

0 comments on commit 411fa62

Please sign in to comment.