Skip to content

Commit 633fd3c

Browse files
Merge pull request #2288 from gnufied/fix-rwx-expansion-behaviour
OCPBUGS-55631: UPSTREAM: 131495: Handle unsupported node expansion for RWX volumes
2 parents 814ec8e + 5d8d263 commit 633fd3c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ func TestNodeExpander(t *testing.T) {
139139
expectFinalErrors: false,
140140
expectedStatusSize: resource.MustParse("2G"),
141141
},
142+
{
143+
name: "RWX pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize, reize_op=unsupported",
144+
pvc: addAccessMode(getTestPVC(volumetesting.FailWithUnSupportedVolumeName, "2G", "2G", "2G", nil), v1.ReadWriteMany),
145+
pv: getTestPV(volumetesting.FailWithUnSupportedVolumeName, "2G"),
146+
recoverVolumeExpansionFailure: true,
147+
expectError: false,
148+
expectedResizeStatus: "",
149+
expectResizeCall: false,
150+
assumeResizeOpAsFinished: true,
151+
expectFinalErrors: false,
152+
expectedStatusSize: resource.MustParse("2G"),
153+
},
142154
{
143155
name: "pv.spec.cap > pvc.status.cap, resizeStatus=node_expansion_pending, featuregate=disabled",
144156
pvc: getTestPVC("test-vol0", "2G", "1G", "2G", &nodeResizePending),

0 commit comments

Comments
 (0)