Skip to content

Commit 95eb3a6

Browse files
authored
Merge pull request kubernetes#77452 from cwdsuzhou/fix_error_overrided
fix always print EventTypeWarning due to err override
2 parents e332051 + 722f42c commit 95eb3a6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pkg/controller/volume/expand/cache/volume_resize_map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewVolumeResizeMap(kubeClient clientset.Interface) VolumeResizeMap {
9292
// AddPVCUpdate adds pvc for resizing
9393
// This function intentionally allows addition of PVCs for which pv.Spec.Size >= pvc.Spec.Size,
9494
// the reason being - lack of transaction in k8s means after successful resize, we can't guarantee that when we update PV,
95-
// pvc update will be successful too and after resize we alyways update PV first.
95+
// pvc update will be successful too and after resize we always update PV first.
9696
// If for some reason we weren't able to update PVC after successful resize, then we are going to reprocess
9797
// the PVC and hopefully after a no-op resize in volume plugin, PVC will be updated with right values as well.
9898
func (resizeMap *volumeResizeMap) AddPVCUpdate(pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) {

pkg/controller/volume/expand/expand_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,16 @@ func (expc *expandController) pvcUpdate(oldObj, newObj interface{}) {
211211
volumeSpec := volume.NewSpecFromPersistentVolume(pv, false)
212212
volumePlugin, err := expc.volumePluginMgr.FindExpandablePluginBySpec(volumeSpec)
213213
if err != nil || volumePlugin == nil {
214-
err = fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
214+
retErr := fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
215215
"waiting for an external controller to process this PVC")
216216
eventType := v1.EventTypeNormal
217217
if err != nil {
218218
eventType = v1.EventTypeWarning
219219
}
220220
expc.recorder.Event(newPVC, eventType, events.ExternalExpanding,
221-
fmt.Sprintf("Ignoring the PVC: %v.", err))
221+
fmt.Sprintf("Ignoring the PVC: %v.", retErr))
222222
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.",
223-
util.GetPersistentVolumeClaimQualifiedName(newPVC), newPVC.UID, err)
223+
util.GetPersistentVolumeClaimQualifiedName(newPVC), newPVC.UID, retErr)
224224
return
225225
}
226226
expc.resizeMap.AddPVCUpdate(newPVC, pv)

pkg/controller/volume/expand/pvc_populator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ func (populator *pvcPopulator) Sync() {
102102
volumeSpec := volume.NewSpecFromPersistentVolume(pv, false)
103103
volumePlugin, err := populator.volumePluginMgr.FindExpandablePluginBySpec(volumeSpec)
104104
if (err != nil || volumePlugin == nil) && pvcStatusSize.Cmp(pvcSize) < 0 {
105-
err = fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
105+
retErr := fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
106106
"waiting for an external controller to process this PVC")
107107
eventType := v1.EventTypeNormal
108108
if err != nil {
109109
eventType = v1.EventTypeWarning
110110
}
111111
populator.recorder.Event(pvc, eventType, events.ExternalExpanding,
112-
fmt.Sprintf("Ignoring the PVC: %v.", err))
112+
fmt.Sprintf("Ignoring the PVC: %v.", retErr))
113113
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.",
114-
util.GetPersistentVolumeClaimQualifiedName(pvc), pvc.UID, err)
114+
util.GetPersistentVolumeClaimQualifiedName(pvc), pvc.UID, retErr)
115115
continue
116116
}
117117

0 commit comments

Comments
 (0)