Skip to content

Commit

Permalink
Fix strict-local volume restore stuck in attaching state
Browse files Browse the repository at this point in the history
For a volume being restored, the spec.nodeID is empyty but the status.ownerID is set.
Thus, set r.Spec.HardNodeAffinity to volume.status.ownerID instead.

Longhorn 6239

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed Jul 10, 2023
1 parent de26d0a commit 8c23346
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,11 +1208,14 @@ func (vc *VolumeController) ReconcileVolumeState(v *longhorn.Volume, es map[stri
continue
}
if v.Spec.DataLocality == longhorn.DataLocalityStrictLocal {
if v.Spec.NodeID == "" {
continue
if v.Status.RestoreRequired {
r.Spec.HardNodeAffinity = v.Status.OwnerID
} else {
if v.Spec.NodeID == "" {
continue
}
r.Spec.HardNodeAffinity = v.Spec.NodeID
}

r.Spec.HardNodeAffinity = v.Spec.NodeID
}

scheduledReplica, multiError, err := vc.scheduler.ScheduleReplica(r, rs, v)
Expand Down
5 changes: 3 additions & 2 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const (
)

// SettingsRelatedToVolume should match the items in datastore.GetLabelsForVolumesFollowsGlobalSettings
// TODO: May need to add the data locality check
// TODO: May need to add the data locality check
var SettingsRelatedToVolume = map[string]string{
string(SettingNameReplicaAutoBalance): LonghornLabelValueIgnored,
string(SettingNameSnapshotDataIntegrity): LonghornLabelValueIgnored,
Expand Down Expand Up @@ -807,7 +807,8 @@ type DiskSpecWithName struct {

// UnmarshalToDisks input format should be:
// `[{"path":"/mnt/disk1","allowScheduling":false},
// {"path":"/mnt/disk2","allowScheduling":false,"storageReserved":1024,"tags":["ssd","fast"]}]`
//
// {"path":"/mnt/disk2","allowScheduling":false,"storageReserved":1024,"tags":["ssd","fast"]}]`
func UnmarshalToDisks(s string) (ret []DiskSpecWithName, err error) {
if err := json.Unmarshal([]byte(s), &ret); err != nil {
return nil, err
Expand Down

0 comments on commit 8c23346

Please sign in to comment.