remove wrong warning event (FileSystemResizeFailed) during a pod creation when it uses a readonly volume.

This commit is contained in:
carlory 2023-12-28 17:46:34 +08:00
parent 1b6b3ba013
commit 5607349e39

View File

@ -2081,6 +2081,9 @@ func (og *operationGenerator) expandVolumeDuringMount(volumeToMount VolumeToMoun
return false, fmt.Errorf("mountVolume.NodeExpandVolume get PVC failed : %v", err)
}
pvcStatusCap := pvc.Status.Capacity[v1.ResourceStorage]
pvSpecCap := pv.Spec.Capacity[v1.ResourceStorage]
if pvcStatusCap.Cmp(pvSpecCap) < 0 {
if volumeToMount.VolumeSpec.ReadOnly {
simpleMsg, detailedMsg := volumeToMount.GenerateMsg("MountVolume.NodeExpandVolume failed", "requested read-only file system")
klog.Warningf(detailedMsg)
@ -2088,9 +2091,7 @@ func (og *operationGenerator) expandVolumeDuringMount(volumeToMount VolumeToMoun
og.recorder.Eventf(pvc, v1.EventTypeWarning, kevents.FileSystemResizeFailed, simpleMsg)
return true, nil
}
pvcStatusCap := pvc.Status.Capacity[v1.ResourceStorage]
pvSpecCap := pv.Spec.Capacity[v1.ResourceStorage]
if pvcStatusCap.Cmp(pvSpecCap) < 0 {
rsOpts.NewSize = pvSpecCap
rsOpts.OldSize = pvcStatusCap
resizeOp := nodeResizeOperationOpts{