Skip to content

Commit 69e0af3

Browse files
committed
Also change final status by removing featuregate check
1 parent 0bec23c commit 69e0af3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pkg/volume/util/operationexecutor/node_expander.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error) {
184184
}
185185

186186
// File system resize succeeded, now update the PVC's Capacity to match the PV's
187-
ne.pvc, err = util.MarkFSResizeFinished(ne.pvc, ne.pluginResizeOpts.NewSize, ne.kubeClient)
187+
ne.pvc, err = util.MarkNodeExpansionFinishedWithRecovery(ne.pvc, ne.pluginResizeOpts.NewSize, ne.kubeClient)
188188
if err != nil {
189189
return true, ne.pluginResizeOpts.NewSize, fmt.Errorf("mountVolume.NodeExpandVolume update pvc status failed: %w", err)
190190
}

pkg/volume/util/resize_util.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,28 @@ func MarkFSResizeFinished(
236236
return updatedPVC, err
237237
}
238238

239+
func MarkNodeExpansionFinishedWithRecovery(
240+
pvc *v1.PersistentVolumeClaim,
241+
newSize resource.Quantity,
242+
kubeClient clientset.Interface) (*v1.PersistentVolumeClaim, error) {
243+
newPVC := pvc.DeepCopy()
244+
245+
newPVC.Status.Capacity[v1.ResourceStorage] = newSize
246+
247+
// if RecoverVolumeExpansionFailure is enabled, we need to reset ResizeStatus back to nil
248+
allocatedResourceStatusMap := newPVC.Status.AllocatedResourceStatuses
249+
delete(allocatedResourceStatusMap, v1.ResourceStorage)
250+
if len(allocatedResourceStatusMap) == 0 {
251+
newPVC.Status.AllocatedResourceStatuses = nil
252+
} else {
253+
newPVC.Status.AllocatedResourceStatuses = allocatedResourceStatusMap
254+
}
255+
256+
newPVC = MergeResizeConditionOnPVC(newPVC, []v1.PersistentVolumeClaimCondition{}, false /* keepOldResizeConditions */)
257+
updatedPVC, err := PatchPVCStatus(pvc /*oldPVC*/, newPVC, kubeClient)
258+
return updatedPVC, err
259+
}
260+
239261
// MarkNodeExpansionInfeasible marks a PVC for node expansion as failed. Kubelet should not retry expansion
240262
// of volumes which are in failed state.
241263
func MarkNodeExpansionInfeasible(pvc *v1.PersistentVolumeClaim, kubeClient clientset.Interface, err error) (*v1.PersistentVolumeClaim, error) {

0 commit comments

Comments
 (0)