Skip to content

Commit b1e8560

Browse files
authored
Merge pull request #500 from sunnylovestiramisu/addEventForError
Add VolumeModifyFailed PVC Event For Nonexistent VAC
2 parents 2e1c582 + c5799e3 commit b1e8560

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/modifycontroller/modify_volume.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"google.golang.org/grpc/status"
2525
v1 "k8s.io/api/core/v1"
2626
storagev1beta1 "k8s.io/api/storage/v1beta1"
27+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2728
"k8s.io/client-go/tools/cache"
2829
"k8s.io/klog/v2"
2930
)
@@ -61,6 +62,9 @@ func (ctrl *modifyController) modify(pvc *v1.PersistentVolumeClaim, pv *v1.Persi
6162
} else {
6263
vac, err := ctrl.vacLister.Get(*pvcSpecVacName)
6364
if err != nil {
65+
if apierrors.IsNotFound(err) {
66+
ctrl.eventRecorder.Eventf(pvc, v1.EventTypeWarning, util.VolumeModifyFailed, "VAC "+*pvcSpecVacName+" does not exist.")
67+
}
6468
return pvc, pv, err, false
6569
}
6670
return ctrl.controllerModifyVolumeWithTarget(pvc, pv, vac, pvcSpecVacName)
@@ -91,6 +95,9 @@ func (ctrl *modifyController) validateVACAndModifyVolumeWithTarget(
9195
fmt.Sprintf("external resizer is modifying volume %s with vac %s", pvc.Name, *pvcSpecVacName))
9296
return ctrl.controllerModifyVolumeWithTarget(pvc, pv, vac, pvcSpecVacName)
9397
} else {
98+
if apierrors.IsNotFound(err) {
99+
ctrl.eventRecorder.Eventf(pvc, v1.EventTypeWarning, util.VolumeModifyFailed, "VAC "+*pvcSpecVacName+" does not exist.")
100+
}
94101
klog.Errorf("Get VAC with vac name %s in VACInformer cache failed: %v", *pvcSpecVacName, err)
95102
// Mark pvc.Status.ModifyVolumeStatus as pending
96103
pvc, err = ctrl.markControllerModifyVolumeStatus(pvc, v1.PersistentVolumeClaimModifyVolumePending, nil)

0 commit comments

Comments
 (0)