mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #115346 from gnufied/set-staging-path-expansion
Set node_stage_path whenever available
This commit is contained in:
commit
f9a3fd2810
@ -669,6 +669,16 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
|
||||
resizeOptions.DeviceStagePath = deviceMountPath
|
||||
}
|
||||
|
||||
if volumeDeviceMounter != nil && resizeOptions.DeviceStagePath == "" {
|
||||
deviceStagePath, err := volumeDeviceMounter.GetDeviceMountPath(volumeToMount.VolumeSpec)
|
||||
if err != nil {
|
||||
// On failure, return error. Caller will log and retry.
|
||||
eventErr, detailedErr := volumeToMount.GenerateError("MountVolume.GetDeviceMountPath failed for expansion", err)
|
||||
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
|
||||
}
|
||||
resizeOptions.DeviceStagePath = deviceStagePath
|
||||
}
|
||||
|
||||
// No mapping is needed for hostUID/hostGID if userns is not used.
|
||||
// Therefore, just assign the container users to host UID/GID.
|
||||
hostUID := util.FsUserFrom(volumeToMount.Pod)
|
||||
|
@ -46,6 +46,7 @@ const (
|
||||
expansionFailed
|
||||
expansionFailedOnController
|
||||
expansionFailedOnNode
|
||||
expansionFailedMissingStagingPath
|
||||
)
|
||||
|
||||
const (
|
||||
@ -78,25 +79,35 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
|
||||
nodeExpansionRequired bool
|
||||
disableAttach bool
|
||||
disableResizingOnDriver bool
|
||||
simulatedCSIDriverError expansionStatus
|
||||
expectFailure bool
|
||||
}{
|
||||
{
|
||||
name: "should expand volume without restarting pod if nodeExpansion=off",
|
||||
nodeExpansionRequired: false,
|
||||
name: "should expand volume without restarting pod if nodeExpansion=off",
|
||||
nodeExpansionRequired: false,
|
||||
simulatedCSIDriverError: expansionSuccess,
|
||||
},
|
||||
{
|
||||
name: "should expand volume by restarting pod if attach=on, nodeExpansion=on",
|
||||
nodeExpansionRequired: true,
|
||||
name: "should expand volume by restarting pod if attach=on, nodeExpansion=on",
|
||||
nodeExpansionRequired: true,
|
||||
simulatedCSIDriverError: expansionSuccess,
|
||||
},
|
||||
{
|
||||
name: "should expand volume by restarting pod if attach=off, nodeExpansion=on",
|
||||
disableAttach: true,
|
||||
nodeExpansionRequired: true,
|
||||
name: "should not have staging_path missing in node expand volume pod if attach=on, nodeExpansion=on",
|
||||
nodeExpansionRequired: true,
|
||||
simulatedCSIDriverError: expansionFailedMissingStagingPath,
|
||||
},
|
||||
{
|
||||
name: "should expand volume by restarting pod if attach=off, nodeExpansion=on",
|
||||
disableAttach: true,
|
||||
nodeExpansionRequired: true,
|
||||
simulatedCSIDriverError: expansionSuccess,
|
||||
},
|
||||
{
|
||||
name: "should not expand volume if resizingOnDriver=off, resizingOnSC=on",
|
||||
disableResizingOnDriver: true,
|
||||
expectFailure: true,
|
||||
simulatedCSIDriverError: expansionSuccess,
|
||||
},
|
||||
}
|
||||
for _, t := range tests {
|
||||
@ -113,6 +124,7 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
|
||||
tp.disableAttach = true
|
||||
tp.registerDriver = true
|
||||
}
|
||||
tp.hooks = createExpansionHook(test.simulatedCSIDriverError)
|
||||
|
||||
m.init(ctx, tp)
|
||||
ginkgo.DeferCleanup(m.cleanup)
|
||||
@ -172,8 +184,12 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
|
||||
}
|
||||
|
||||
ginkgo.By("Deleting the previously created pod")
|
||||
err = e2epod.DeletePodWithWait(ctx, m.cs, pod)
|
||||
framework.ExpectNoError(err, "while deleting pod for resizing")
|
||||
if test.simulatedCSIDriverError == expansionFailedMissingStagingPath {
|
||||
e2epod.DeletePodOrFail(ctx, m.cs, pod.Namespace, pod.Name)
|
||||
} else {
|
||||
err = e2epod.DeletePodWithWait(ctx, m.cs, pod)
|
||||
framework.ExpectNoError(err, "while deleting pod for resizing")
|
||||
}
|
||||
|
||||
ginkgo.By("Creating a new pod with same volume")
|
||||
pod2, err := m.createPodWithPVC(pvc)
|
||||
@ -445,6 +461,15 @@ func createExpansionHook(expectedExpansionStatus expansionStatus) *drivers.Hooks
|
||||
return &drivers.Hooks{
|
||||
Pre: func(ctx context.Context, method string, request interface{}) (reply interface{}, err error) {
|
||||
switch expectedExpansionStatus {
|
||||
case expansionFailedMissingStagingPath:
|
||||
expansionRequest, ok := request.(*csipbv1.NodeExpandVolumeRequest)
|
||||
if ok {
|
||||
stagingPath := expansionRequest.StagingTargetPath
|
||||
if stagingPath == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid node expansion request, missing staging path")
|
||||
}
|
||||
|
||||
}
|
||||
case expansionFailedOnController:
|
||||
expansionRequest, ok := request.(*csipbv1.ControllerExpandVolumeRequest)
|
||||
if ok {
|
||||
|
Loading…
Reference in New Issue
Block a user