Preserve conditions in case we are retrying expansion in some cases

When marking pvc expansion for failed condition, we should try and
preserve old resizing conditions with different name.
This commit is contained in:
Hemant Kumar
2024-07-16 13:16:48 -04:00
parent b3db0ba04c
commit b59c3c5d3d
2 changed files with 47 additions and 14 deletions

View File

@@ -33,10 +33,11 @@ import (
)
type conditionMergeTestCase struct {
description string
pvc *v1.PersistentVolumeClaim
newConditions []v1.PersistentVolumeClaimCondition
finalConditions []v1.PersistentVolumeClaimCondition
description string
pvc *v1.PersistentVolumeClaim
keepOldResizeConditions bool
newConditions []v1.PersistentVolumeClaimCondition
finalConditions []v1.PersistentVolumeClaimCondition
}
func TestMergeResizeCondition(t *testing.T) {
@@ -132,10 +133,34 @@ func TestMergeResizeCondition(t *testing.T) {
},
},
},
{
description: "when adding new condition with existing resize conditions",
pvc: pvc.DeepCopy(),
keepOldResizeConditions: true,
newConditions: []v1.PersistentVolumeClaimCondition{
{
Type: v1.PersistentVolumeClaimNodeResizeError,
Status: v1.ConditionTrue,
LastTransitionTime: currentTime,
},
},
finalConditions: []v1.PersistentVolumeClaimCondition{
{
Type: v1.PersistentVolumeClaimResizing,
Status: v1.ConditionTrue,
LastTransitionTime: currentTime,
},
{
Type: v1.PersistentVolumeClaimNodeResizeError,
Status: v1.ConditionTrue,
LastTransitionTime: currentTime,
},
},
},
}
for _, testcase := range testCases {
updatePVC := MergeResizeConditionOnPVC(testcase.pvc, testcase.newConditions)
updatePVC := MergeResizeConditionOnPVC(testcase.pvc, testcase.newConditions, testcase.keepOldResizeConditions)
updateConditions := updatePVC.Status.Conditions
if !reflect.DeepEqual(updateConditions, testcase.finalConditions) {