From 49e82fd12012c9e57411ded2f12d3461acf93994 Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Wed, 10 Jul 2024 12:02:54 -0400 Subject: [PATCH] Rename ReizeFailed conditions to ResizeInfeasible --- pkg/apis/core/types.go | 9 +++++---- pkg/apis/core/validation/validation.go | 4 ++-- pkg/apis/core/validation/validation_test.go | 6 +++--- pkg/volume/util/operationexecutor/operation_generator.go | 6 +++--- pkg/volume/util/resize_util.go | 2 +- pkg/volume/util/resize_util_test.go | 8 ++++---- staging/src/k8s.io/api/core/v1/types.go | 9 +++++---- test/e2e/storage/csimock/csi_volume_expansion.go | 6 +++--- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index 41f435ba0bf..9e1a1b709e3 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -572,18 +572,19 @@ const ( // State set when resize controller starts resizing the volume in control-plane PersistentVolumeClaimControllerResizeInProgress ClaimResourceStatus = "ControllerResizeInProgress" - // State set when resize has failed in resize controller with a terminal error. + // State set when resize has failed in resize controller with a terminal unrecoverable error. // Transient errors such as timeout should not set this status and should leave allocatedResourceStatus // unmodified, so as resize controller can resume the volume expansion. - PersistentVolumeClaimControllerResizeFailed ClaimResourceStatus = "ControllerResizeFailed" + PersistentVolumeClaimControllerResizeInfeasible ClaimResourceStatus = "ControllerResizeInfeasible" // State set when resize controller has finished resizing the volume but further resizing of volume // is needed on the node. PersistentVolumeClaimNodeResizePending ClaimResourceStatus = "NodeResizePending" // State set when kubelet starts resizing the volume. PersistentVolumeClaimNodeResizeInProgress ClaimResourceStatus = "NodeResizeInProgress" - // State set when resizing has failed in kubelet with a terminal error. Transient errors don't set NodeResizeFailed - PersistentVolumeClaimNodeResizeFailed ClaimResourceStatus = "NodeResizeFailed" + // State set when resizing has failed in kubelet with a terminal unrecoverable error. Transient errors + // shouldn't set this status + PersistentVolumeClaimNodeResizeInfeasible ClaimResourceStatus = "NodeResizeInfeasible" ) // +enum diff --git a/pkg/apis/core/validation/validation.go b/pkg/apis/core/validation/validation.go index e0841d0c21b..864df20738e 100644 --- a/pkg/apis/core/validation/validation.go +++ b/pkg/apis/core/validation/validation.go @@ -2481,10 +2481,10 @@ func validatePersistentVolumeClaimResourceKey(value string, fldPath *field.Path) } var resizeStatusSet = sets.New(core.PersistentVolumeClaimControllerResizeInProgress, - core.PersistentVolumeClaimControllerResizeFailed, + core.PersistentVolumeClaimControllerResizeInfeasible, core.PersistentVolumeClaimNodeResizePending, core.PersistentVolumeClaimNodeResizeInProgress, - core.PersistentVolumeClaimNodeResizeFailed) + core.PersistentVolumeClaimNodeResizeInfeasible) // ValidatePersistentVolumeClaimStatusUpdate validates an update to status of a PersistentVolumeClaim func ValidatePersistentVolumeClaimStatusUpdate(newPvc, oldPvc *core.PersistentVolumeClaim, validationOpts PersistentVolumeClaimSpecValidationOptions) field.ErrorList { diff --git a/pkg/apis/core/validation/validation_test.go b/pkg/apis/core/validation/validation_test.go index 65d5a2236e3..6f22c96b814 100644 --- a/pkg/apis/core/validation/validation_test.go +++ b/pkg/apis/core/validation/validation_test.go @@ -18971,7 +18971,7 @@ func TestValidatePersistentVolumeClaimStatusUpdate(t *testing.T) { }, }, core.PersistentVolumeClaimStatus{ AllocatedResourceStatuses: map[core.ResourceName]core.ClaimResourceStatus{ - core.ResourceStorage: core.PersistentVolumeClaimControllerResizeFailed, + core.ResourceStorage: core.PersistentVolumeClaimControllerResizeInfeasible, }, }) @@ -19001,7 +19001,7 @@ func TestValidatePersistentVolumeClaimStatusUpdate(t *testing.T) { }, }, core.PersistentVolumeClaimStatus{ AllocatedResourceStatuses: map[core.ResourceName]core.ClaimResourceStatus{ - core.ResourceStorage: core.PersistentVolumeClaimNodeResizeFailed, + core.ResourceStorage: core.PersistentVolumeClaimNodeResizeInfeasible, }, }) @@ -19045,7 +19045,7 @@ func TestValidatePersistentVolumeClaimStatusUpdate(t *testing.T) { validResizeKeyCustom: resource.MustParse("10Gi"), }, AllocatedResourceStatuses: map[core.ResourceName]core.ClaimResourceStatus{ - core.ResourceStorage: core.PersistentVolumeClaimControllerResizeFailed, + core.ResourceStorage: core.PersistentVolumeClaimControllerResizeInfeasible, validResizeKeyCustom: core.PersistentVolumeClaimControllerResizeInProgress, }, }) diff --git a/pkg/volume/util/operationexecutor/operation_generator.go b/pkg/volume/util/operationexecutor/operation_generator.go index 06f96024c33..83566f4c5bf 100644 --- a/pkg/volume/util/operationexecutor/operation_generator.go +++ b/pkg/volume/util/operationexecutor/operation_generator.go @@ -1718,7 +1718,7 @@ func (og *operationGenerator) expandAndRecoverFunction(resizeOpts inTreeResizeOp case v1.PersistentVolumeClaimControllerResizeInProgress, v1.PersistentVolumeClaimNodeResizePending, v1.PersistentVolumeClaimNodeResizeInProgress, - v1.PersistentVolumeClaimNodeResizeFailed: + v1.PersistentVolumeClaimNodeResizeInfeasible: if allocatedSize != nil { newSize = *allocatedSize } @@ -1742,14 +1742,14 @@ func (og *operationGenerator) expandAndRecoverFunction(resizeOpts inTreeResizeOp // we don't need to do any work. We could be here because of a spurious update event. // This is case #1 return resizeResponse - case v1.PersistentVolumeClaimNodeResizeFailed: + case v1.PersistentVolumeClaimNodeResizeInfeasible: // This is case#3 pvc, err = og.markForPendingNodeExpansion(pvc, pv) resizeResponse.pvc = pvc resizeResponse.err = err return resizeResponse case v1.PersistentVolumeClaimControllerResizeInProgress, - v1.PersistentVolumeClaimControllerResizeFailed: + v1.PersistentVolumeClaimControllerResizeInfeasible: // This is case#2 or it could also be case#4 when user manually shrunk the PVC // after expanding it. if allocatedSize != nil { diff --git a/pkg/volume/util/resize_util.go b/pkg/volume/util/resize_util.go index 0f1495f7b34..aaa93d7b1e5 100644 --- a/pkg/volume/util/resize_util.go +++ b/pkg/volume/util/resize_util.go @@ -238,7 +238,7 @@ func MarkFSResizeFinished( // of volumes which are in failed state. func MarkNodeExpansionFailed(pvc *v1.PersistentVolumeClaim, kubeClient clientset.Interface) (*v1.PersistentVolumeClaim, error) { newPVC := pvc.DeepCopy() - newPVC = mergeStorageResourceStatus(newPVC, v1.PersistentVolumeClaimNodeResizeFailed) + newPVC = mergeStorageResourceStatus(newPVC, v1.PersistentVolumeClaimNodeResizeInfeasible) patchBytes, err := createPVCPatch(pvc, newPVC, false /* addResourceVersionCheck */) if err != nil { diff --git a/pkg/volume/util/resize_util_test.go b/pkg/volume/util/resize_util_test.go index 2292ee91513..7b244c96cfd 100644 --- a/pkg/volume/util/resize_util_test.go +++ b/pkg/volume/util/resize_util_test.go @@ -166,8 +166,8 @@ func TestResizeFunctions(t *testing.T) { }, { name: "mark fs resize, when other resource statuses are present", - pvc: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeFailed).get(), - expectedPVC: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeFailed). + pvc: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeInfeasible).get(), + expectedPVC: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeInfeasible). withStorageResourceStatus(v1.PersistentVolumeClaimNodeResizePending).get(), testFunc: func(pvc *v1.PersistentVolumeClaim, c clientset.Interface, _ resource.Quantity) (*v1.PersistentVolumeClaim, error) { return MarkForFSResize(pvc, c) @@ -183,9 +183,9 @@ func TestResizeFunctions(t *testing.T) { }, { name: "mark resize finished", - pvc: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeFailed). + pvc: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeInfeasible). withStorageResourceStatus(v1.PersistentVolumeClaimNodeResizePending).get(), - expectedPVC: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeFailed). + expectedPVC: basePVC.withResourceStatus(v1.ResourceCPU, v1.PersistentVolumeClaimControllerResizeInfeasible). withStorageResourceStatus("").get(), testFunc: func(pvc *v1.PersistentVolumeClaim, i clientset.Interface, q resource.Quantity) (*v1.PersistentVolumeClaim, error) { return MarkFSResizeFinished(pvc, q, i) diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index ea60ddf2c86..0adf0b4679c 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -624,18 +624,19 @@ const ( // State set when resize controller starts resizing the volume in control-plane. PersistentVolumeClaimControllerResizeInProgress ClaimResourceStatus = "ControllerResizeInProgress" - // State set when resize has failed in resize controller with a terminal error. + // State set when resize has failed in resize controller with a terminal unrecoverable error. // Transient errors such as timeout should not set this status and should leave allocatedResourceStatus // unmodified, so as resize controller can resume the volume expansion. - PersistentVolumeClaimControllerResizeFailed ClaimResourceStatus = "ControllerResizeFailed" + PersistentVolumeClaimControllerResizeInfeasible ClaimResourceStatus = "ControllerResizeInfeasible" // State set when resize controller has finished resizing the volume but further resizing of volume // is needed on the node. PersistentVolumeClaimNodeResizePending ClaimResourceStatus = "NodeResizePending" // State set when kubelet starts resizing the volume. PersistentVolumeClaimNodeResizeInProgress ClaimResourceStatus = "NodeResizeInProgress" - // State set when resizing has failed in kubelet with a terminal error. Transient errors don't set NodeResizeFailed - PersistentVolumeClaimNodeResizeFailed ClaimResourceStatus = "NodeResizeFailed" + // State set when resizing has failed in kubelet with a terminal unrecoverable error. Transient errors + // shouldn't set this status + PersistentVolumeClaimNodeResizeInfeasible ClaimResourceStatus = "NodeResizeInfeasible" ) // +enum diff --git a/test/e2e/storage/csimock/csi_volume_expansion.go b/test/e2e/storage/csimock/csi_volume_expansion.go index bf55eec8404..3edf98736fd 100644 --- a/test/e2e/storage/csimock/csi_volume_expansion.go +++ b/test/e2e/storage/csimock/csi_volume_expansion.go @@ -411,7 +411,7 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() { pvcRequestSize: "11Gi", // expansion to 11Gi will cause expansion to fail on controller allocatedResource: "11Gi", simulatedCSIDriverError: expansionFailedOnController, - expectedResizeStatus: v1.PersistentVolumeClaimControllerResizeFailed, + expectedResizeStatus: v1.PersistentVolumeClaimControllerResizeInfeasible, recoverySize: resource.MustParse("4Gi"), }, { @@ -419,7 +419,7 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() { pvcRequestSize: "9Gi", // expansion to 9Gi will cause expansion to fail on node allocatedResource: "9Gi", simulatedCSIDriverError: expansionFailedOnNode, - expectedResizeStatus: v1.PersistentVolumeClaimNodeResizeFailed, + expectedResizeStatus: v1.PersistentVolumeClaimNodeResizeInfeasible, recoverySize: resource.MustParse("5Gi"), }, } @@ -500,7 +500,7 @@ func validateRecoveryBehaviour(ctx context.Context, pvc *v1.PersistentVolumeClai // if expansion succeeded on controller but failed on the node if test.simulatedCSIDriverError == expansionFailedOnNode { ginkgo.By("Wait for expansion to fail on node again") - err = waitForResizeStatus(pvc, m.cs, v1.PersistentVolumeClaimNodeResizeFailed) + err = waitForResizeStatus(pvc, m.cs, v1.PersistentVolumeClaimNodeResizeInfeasible) framework.ExpectNoError(err, "While waiting for resize status to be set to expansion-failed-on-node") ginkgo.By("verify allocated resources after recovery")