From fde42bdb58dcddf391c2a0ab5acca68e0bd252f4 Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Sun, 25 Feb 2024 00:31:49 +0100 Subject: [PATCH 1/2] Support changing volume size --- webhook/resources/volume/validator.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/webhook/resources/volume/validator.go b/webhook/resources/volume/validator.go index 30cb50575a..b3dc40d225 100644 --- a/webhook/resources/volume/validator.go +++ b/webhook/resources/volume/validator.go @@ -244,12 +244,6 @@ func (v *volumeValidator) Update(request *admission.Request, oldObj runtime.Obje if datastore.IsDataEngineV2(newVolume.Spec.DataEngine) { // TODO: remove this check when we support the following features for SPDK volumes - if oldVolume.Spec.Size != newVolume.Spec.Size { - err := fmt.Errorf("changing volume size for volume %v is not supported for data engine %v", - newVolume.Name, newVolume.Spec.DataEngine) - return werror.NewInvalidError(err.Error(), "") - } - if oldVolume.Spec.NumberOfReplicas != newVolume.Spec.NumberOfReplicas { err := fmt.Errorf("changing number of replicas for volume %v is not supported for data engine %v", newVolume.Name, newVolume.Spec.DataEngine) From 784e24f86d707d98f66a335c40ab43e51a2eb6c9 Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Fri, 1 Mar 2024 10:18:21 +0100 Subject: [PATCH 2/2] Only check API version for v1 volumes --- controller/engine_controller.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/controller/engine_controller.go b/controller/engine_controller.go index 0a9a38ebfc..8c4ff4e1c6 100644 --- a/controller/engine_controller.go +++ b/controller/engine_controller.go @@ -1261,18 +1261,20 @@ func IsValidForExpansion(engine *longhorn.Engine, cliAPIVersion, imAPIVersion in return false, fmt.Errorf("the expected size %v of engine %v should not be smaller than the current size %v", engine.Spec.VolumeSize, engine.Name, engine.Status.CurrentSize) } - if cliAPIVersion < engineapi.CLIAPIMinVersionForExistingEngineBeforeUpgrade { - return false, nil - } + if datastore.IsDataEngineV1(engine.Spec.DataEngine) { + if cliAPIVersion < engineapi.CLIAPIMinVersionForExistingEngineBeforeUpgrade { + return false, nil + } - if !engineapi.IsEndpointTGTBlockDev(engine.Status.Endpoint) { - return true, nil - } - if cliAPIVersion < 7 { - return false, fmt.Errorf("failed to do online expansion for the old engine %v with cli API version %v", engine.Name, cliAPIVersion) - } - if imAPIVersion < 3 { - return false, fmt.Errorf("failed do online expansion for the engine %v in the instance manager with API version %v", engine.Name, imAPIVersion) + if !engineapi.IsEndpointTGTBlockDev(engine.Status.Endpoint) { + return true, nil + } + if cliAPIVersion < 7 { + return false, fmt.Errorf("failed to do online expansion for the old engine %v with cli API version %v", engine.Name, cliAPIVersion) + } + if imAPIVersion < 3 { + return false, fmt.Errorf("failed do online expansion for the engine %v in the instance manager with API version %v", engine.Name, imAPIVersion) + } } return true, nil