Merge pull request #115304 from gnufied/fix-version-skew-for-older-expansion-controller

Use expansion without recovery if allocatedResource/resizeStatus unset
This commit is contained in:
Kubernetes Prow Robot 2023-01-27 02:36:25 -08:00 committed by GitHub
commit 4d9e8f7695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2103,7 +2103,7 @@ func (og *operationGenerator) expandVolumeDuringMount(volumeToMount VolumeToMoun
volumePlugin: expandablePlugin,
actualStateOfWorld: actualStateOfWorld,
}
if utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure) {
if og.checkForRecoveryFromExpansion(pvc, volumeToMount) {
nodeExpander := newNodeExpander(resizeOp, og.kubeClient, og.recorder)
resizeFinished, err, _ := nodeExpander.expandOnPlugin()
return resizeFinished, err
@ -2165,7 +2165,8 @@ func (og *operationGenerator) nodeExpandVolume(
volumePlugin: expandableVolumePlugin,
actualStateOfWorld: actualStateOfWorld,
}
if utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure) {
if og.checkForRecoveryFromExpansion(pvc, volumeToMount) {
nodeExpander := newNodeExpander(resizeOp, og.kubeClient, og.recorder)
resizeFinished, err, _ := nodeExpander.expandOnPlugin()
return resizeFinished, err
@ -2177,6 +2178,26 @@ func (og *operationGenerator) nodeExpandVolume(
return true, nil
}
func (og *operationGenerator) checkForRecoveryFromExpansion(pvc *v1.PersistentVolumeClaim, volumeToMount VolumeToMount) bool {
resizeStatus := pvc.Status.ResizeStatus
allocatedResource := pvc.Status.AllocatedResources
featureGateStatus := utilfeature.DefaultFeatureGate.Enabled(features.RecoverVolumeExpansionFailure)
if !featureGateStatus {
return false
}
// Even though RecoverVolumeExpansionFailure feature gate is enabled, it appears that we are running with older version
// of resize controller, which will not populate allocatedResource and resizeStatus. This can happen because of version skew
// and hence we are going to keep expanding using older logic.
if resizeStatus == nil && allocatedResource == nil {
_, detailedMsg := volumeToMount.GenerateMsg("MountVolume.NodeExpandVolume running with", "older external resize controller")
klog.Warningf(detailedMsg)
return false
}
return true
}
// legacyCallNodeExpandOnPlugin is old version of calling node expansion on plugin, which does not support
// recovery from volume expansion failure
// TODO: Removing this code when RecoverVolumeExpansionFailure feature goes GA.