Skip to content

Commit 5ad726c

Browse files
carlorygnufied
andcommitted
Handle unsupported node expansion for RWX volumes
Co-authored-by: Hemant Kumar <[email protected]> Signed-off-by: carlory <[email protected]>
1 parent 1b7bbcf commit 5ad726c

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
@@ -131,6 +131,17 @@ func TestNodeExpander(t *testing.T) {
131131
expectFinalErrors: false,
132132
expectedStatusSize: resource.MustParse("2G"),
133133
},
134+
{
135+
name: "RWX pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize, reize_op=unsupported",
136+
pvc: addAccessMode(getTestPVC(volumetesting.FailWithUnSupportedVolumeName, "2G", "2G", "2G", nil), v1.ReadWriteMany),
137+
pv: getTestPV(volumetesting.FailWithUnSupportedVolumeName, "2G"),
138+
expectError: false,
139+
expectedResizeStatus: "",
140+
expectResizeCall: false,
141+
assumeResizeOpAsFinished: true,
142+
expectFinalErrors: false,
143+
expectedStatusSize: resource.MustParse("2G"),
144+
},
134145
}
135146

136147
for i := range tests {

0 commit comments

Comments
 (0)