Skip to content

Commit 3f75cae

Browse files
authored
Merge pull request kubernetes#131524 from carlory/automated-cherry-pick-of-#131495-release-1.32
Automated cherry pick of kubernetes#131495: Handle unsupported node expansion for RWX volumes
2 parents 55a2f43 + 5ad726c commit 3f75cae

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pkg/volume/util/operationexecutor/node_expander.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error) {
144144
}
145145
_, resizeErr := ne.volumePlugin.NodeExpand(ne.pluginResizeOpts)
146146
if resizeErr != nil {
147+
// In order to support node volume expansion for RWX volumes on different nodes,
148+
// we bypass the check for VolumeExpansionPendingOnNode state during the pre-check
149+
// and then directly call the NodeExpandVolume method on the plugin.
150+
//
151+
// However, it does not make sense where the csi driver does not support node expansion.
152+
// We should not treat this as a failure. It is a workaround for this issue:
153+
// https://github.com/kubernetes/kubernetes/issues/131381.
154+
//
155+
// For other access modes, we should not hit this state, because we will wait for
156+
// VolumeExpansionPendingOnNode before trying to expand volume in kubelet.
157+
// See runPreCheck() above.
158+
//
159+
// If volume is already expanded, then we should not retry expansion on the node if
160+
// driver returns OperationNotSupportedError.
161+
if volumetypes.IsOperationNotSupportedError(resizeErr) && ne.pvcAlreadyUpdated {
162+
klog.V(4).InfoS(ne.vmt.GenerateMsgDetailed("MountVolume.NodeExpandVolume failed", "NodeExpandVolume not supported"), "pod", klog.KObj(ne.vmt.Pod))
163+
ne.testStatus = testResponseData{assumeResizeFinished: true, resizeCalledOnPlugin: false}
164+
return true, ne.pluginResizeOpts.NewSize, nil
165+
}
166+
147167
if volumetypes.IsOperationFinishedError(resizeErr) {
148168
var markFailedError error
149169
ne.actualStateOfWorld.MarkVolumeExpansionFailedWithFinalError(ne.vmt.VolumeName)

pkg/volume/util/operationexecutor/node_expander_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ func TestNodeExpander(t *testing.T) {
151151
expectFinalErrors: false,
152152
expectedStatusSize: resource.MustParse("2G"),
153153
},
154+
{
155+
name: "RWX pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize, reize_op=unsupported",
156+
pvc: addAccessMode(getTestPVC(volumetesting.FailWithUnSupportedVolumeName, "2G", "2G", "2G", nil), v1.ReadWriteMany),
157+
pv: getTestPV(volumetesting.FailWithUnSupportedVolumeName, "2G"),
158+
expectError: false,
159+
expectedResizeStatus: "",
160+
expectResizeCall: false,
161+
assumeResizeOpAsFinished: true,
162+
expectFinalErrors: false,
163+
expectedStatusSize: resource.MustParse("2G"),
164+
},
154165
}
155166

156167
for i := range tests {

0 commit comments

Comments
 (0)