mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
fix always print EventTypeWarning due to err overrided
This commit is contained in:
parent
ebe32557bc
commit
722f42caba
@ -92,7 +92,7 @@ func NewVolumeResizeMap(kubeClient clientset.Interface) VolumeResizeMap {
|
|||||||
// AddPVCUpdate adds pvc for resizing
|
// AddPVCUpdate adds pvc for resizing
|
||||||
// This function intentionally allows addition of PVCs for which pv.Spec.Size >= pvc.Spec.Size,
|
// This function intentionally allows addition of PVCs for which pv.Spec.Size >= pvc.Spec.Size,
|
||||||
// the reason being - lack of transaction in k8s means after successful resize, we can't guarantee that when we update PV,
|
// the reason being - lack of transaction in k8s means after successful resize, we can't guarantee that when we update PV,
|
||||||
// pvc update will be successful too and after resize we alyways update PV first.
|
// pvc update will be successful too and after resize we always update PV first.
|
||||||
// If for some reason we weren't able to update PVC after successful resize, then we are going to reprocess
|
// If for some reason we weren't able to update PVC after successful resize, then we are going to reprocess
|
||||||
// the PVC and hopefully after a no-op resize in volume plugin, PVC will be updated with right values as well.
|
// the PVC and hopefully after a no-op resize in volume plugin, PVC will be updated with right values as well.
|
||||||
func (resizeMap *volumeResizeMap) AddPVCUpdate(pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) {
|
func (resizeMap *volumeResizeMap) AddPVCUpdate(pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) {
|
||||||
|
@ -211,16 +211,16 @@ func (expc *expandController) pvcUpdate(oldObj, newObj interface{}) {
|
|||||||
volumeSpec := volume.NewSpecFromPersistentVolume(pv, false)
|
volumeSpec := volume.NewSpecFromPersistentVolume(pv, false)
|
||||||
volumePlugin, err := expc.volumePluginMgr.FindExpandablePluginBySpec(volumeSpec)
|
volumePlugin, err := expc.volumePluginMgr.FindExpandablePluginBySpec(volumeSpec)
|
||||||
if err != nil || volumePlugin == nil {
|
if err != nil || volumePlugin == nil {
|
||||||
err = fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
|
retErr := fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
|
||||||
"waiting for an external controller to process this PVC")
|
"waiting for an external controller to process this PVC")
|
||||||
eventType := v1.EventTypeNormal
|
eventType := v1.EventTypeNormal
|
||||||
if err != nil {
|
if err != nil {
|
||||||
eventType = v1.EventTypeWarning
|
eventType = v1.EventTypeWarning
|
||||||
}
|
}
|
||||||
expc.recorder.Event(newPVC, eventType, events.ExternalExpanding,
|
expc.recorder.Event(newPVC, eventType, events.ExternalExpanding,
|
||||||
fmt.Sprintf("Ignoring the PVC: %v.", err))
|
fmt.Sprintf("Ignoring the PVC: %v.", retErr))
|
||||||
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.",
|
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.",
|
||||||
util.GetPersistentVolumeClaimQualifiedName(newPVC), newPVC.UID, err)
|
util.GetPersistentVolumeClaimQualifiedName(newPVC), newPVC.UID, retErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
expc.resizeMap.AddPVCUpdate(newPVC, pv)
|
expc.resizeMap.AddPVCUpdate(newPVC, pv)
|
||||||
|
@ -102,16 +102,16 @@ func (populator *pvcPopulator) Sync() {
|
|||||||
volumeSpec := volume.NewSpecFromPersistentVolume(pv, false)
|
volumeSpec := volume.NewSpecFromPersistentVolume(pv, false)
|
||||||
volumePlugin, err := populator.volumePluginMgr.FindExpandablePluginBySpec(volumeSpec)
|
volumePlugin, err := populator.volumePluginMgr.FindExpandablePluginBySpec(volumeSpec)
|
||||||
if (err != nil || volumePlugin == nil) && pvcStatusSize.Cmp(pvcSize) < 0 {
|
if (err != nil || volumePlugin == nil) && pvcStatusSize.Cmp(pvcSize) < 0 {
|
||||||
err = fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
|
retErr := fmt.Errorf("didn't find a plugin capable of expanding the volume; " +
|
||||||
"waiting for an external controller to process this PVC")
|
"waiting for an external controller to process this PVC")
|
||||||
eventType := v1.EventTypeNormal
|
eventType := v1.EventTypeNormal
|
||||||
if err != nil {
|
if err != nil {
|
||||||
eventType = v1.EventTypeWarning
|
eventType = v1.EventTypeWarning
|
||||||
}
|
}
|
||||||
populator.recorder.Event(pvc, eventType, events.ExternalExpanding,
|
populator.recorder.Event(pvc, eventType, events.ExternalExpanding,
|
||||||
fmt.Sprintf("Ignoring the PVC: %v.", err))
|
fmt.Sprintf("Ignoring the PVC: %v.", retErr))
|
||||||
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.",
|
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.",
|
||||||
util.GetPersistentVolumeClaimQualifiedName(pvc), pvc.UID, err)
|
util.GetPersistentVolumeClaimQualifiedName(pvc), pvc.UID, retErr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user