Skip to content

Commit

Permalink
fix(upgrade): block live upgrade of strict-local
Browse files Browse the repository at this point in the history
Signed-off-by: James Munson <james.munson@suse.com>
(cherry picked from commit 3e47ccc)
  • Loading branch information
james-munson authored and mergify[bot] committed Sep 12, 2024
1 parent 41aee21 commit 4189b54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controller/engine_image_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ func (ic *EngineImageController) canDoOfflineEngineImageUpgrade(v *longhorn.Volu
// 3. Volume is not a DR volume AND
// 4. Volume is not expanding AND
// 5. Volume is not migrating AND
// 6. The current volume's engine image is compatible with the new engine image
// 6. Volume is not strict-local AND
// 7. The current volume's engine image is compatible with the new engine image
func (ic *EngineImageController) canDoLiveEngineImageUpgrade(v *longhorn.Volume, newEngineImageResource *longhorn.EngineImage) bool {
if v.Status.State != longhorn.VolumeStateAttached {
return false
Expand All @@ -532,6 +533,9 @@ func (ic *EngineImageController) canDoLiveEngineImageUpgrade(v *longhorn.Volume,
if util.IsVolumeMigrating(v) {
return false
}
if v.Spec.DataLocality == longhorn.DataLocalityStrictLocal {
return false
}
oldEngineImageResource, err := ic.ds.GetEngineImage(types.GetEngineImageChecksumName(v.Status.CurrentImage))
if err != nil {
return false
Expand Down
4 changes: 4 additions & 0 deletions manager/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ func (m *VolumeManager) EngineUpgrade(volumeName, image string) (v *longhorn.Vol
return nil, fmt.Errorf("cannot do live upgrade for a unhealthy volume %v", v.Name)
}

if v.Status.State == longhorn.VolumeStateAttached && v.Spec.DataLocality == longhorn.DataLocalityStrictLocal {
return nil, fmt.Errorf("cannot do live upgrade for an attached strict-local volume %v", v.Name)
}

oldImage := v.Spec.Image
v.Spec.Image = image

Expand Down

0 comments on commit 4189b54

Please sign in to comment.