@@ -18,10 +18,12 @@ package modifycontroller
18
18
19
19
import (
20
20
"fmt"
21
+
21
22
"github.com/kubernetes-csi/external-resizer/pkg/util"
22
23
v1 "k8s.io/api/core/v1"
23
24
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
25
"k8s.io/client-go/tools/cache"
26
+ "k8s.io/utils/ptr"
25
27
)
26
28
27
29
// markControllerModifyVolumeStatus will mark ModifyVolumeStatus other than completed in the PVC
@@ -31,10 +33,10 @@ func (ctrl *modifyController) markControllerModifyVolumeStatus(
31
33
err error ) (* v1.PersistentVolumeClaim , error ) {
32
34
33
35
newPVC := pvc .DeepCopy ()
34
- if newPVC .Status .ModifyVolumeStatus == nil {
35
- newPVC .Status .ModifyVolumeStatus = & v1.ModifyVolumeStatus {}
36
+ newPVC .Status .ModifyVolumeStatus = & v1.ModifyVolumeStatus {
37
+ Status : modifyVolumeStatus ,
38
+ TargetVolumeAttributesClassName : ptr .Deref (pvc .Spec .VolumeAttributesClassName , "" ),
36
39
}
37
- newPVC .Status .ModifyVolumeStatus .Status = modifyVolumeStatus
38
40
// Update PVC's Condition to indicate modification
39
41
pvcCondition := v1.PersistentVolumeClaimCondition {
40
42
Type : v1 .PersistentVolumeClaimVolumeModifyingVolume ,
@@ -45,7 +47,6 @@ func (ctrl *modifyController) markControllerModifyVolumeStatus(
45
47
switch modifyVolumeStatus {
46
48
case v1 .PersistentVolumeClaimModifyVolumeInProgress :
47
49
conditionMessage = "ModifyVolume operation in progress."
48
- newPVC .Status .ModifyVolumeStatus .TargetVolumeAttributesClassName = * pvc .Spec .VolumeAttributesClassName
49
50
case v1 .PersistentVolumeClaimModifyVolumeInfeasible :
50
51
conditionMessage = "ModifyVolume failed with error" + err .Error () + ". Waiting for retry."
51
52
}
0 commit comments