Skip to content

Commit 69613da

Browse files
committed
rename volumeid to volumeID
1 parent 75e13e3 commit 69613da

File tree

8 files changed

+30
-22
lines changed

8 files changed

+30
-22
lines changed

pkg/volume/csi/csi_block_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func TestBlockMapperSetupDeviceError(t *testing.T) {
277277
}
278278
t.Log("created attachement ", attachID)
279279

280-
err = csiMapper.SetUpDevice()
280+
stagingPath, err := csiMapper.SetUpDevice()
281281
if err == nil {
282282
t.Fatal("mapper unexpectedly succeeded")
283283
}
@@ -292,7 +292,7 @@ func TestBlockMapperSetupDeviceError(t *testing.T) {
292292
if _, err := os.Stat(devDir); err == nil {
293293
t.Errorf("volume publish device directory %s was not deleted", devDir)
294294
}
295-
stagingPath := csiMapper.getStagingPath()
295+
296296
if _, err := os.Stat(stagingPath); err == nil {
297297
t.Errorf("volume staging path %s was not deleted", stagingPath)
298298
}
@@ -474,12 +474,11 @@ func TestVolumeSetupTeardown(t *testing.T) {
474474
}
475475
t.Log("created attachement ", attachID)
476476

477-
err = csiMapper.SetUpDevice()
477+
stagingPath, err := csiMapper.SetUpDevice()
478478
if err != nil {
479479
t.Fatalf("mapper failed to SetupDevice: %v", err)
480480
}
481481
// Check if NodeStageVolume staged to the right path
482-
stagingPath := csiMapper.getStagingPath()
483482
svols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
484483
svol, ok := svols[csiMapper.volumeID]
485484
if !ok {

pkg/volume/csi/csi_client.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ type csiDriverClient struct {
9696
}
9797

9898
type csiResizeOptions struct {
99-
volumeid string
99+
volumeID string
100+
// volumePath is path where volume is available. It could be:
101+
// - path where node is staged if NodeExpandVolume is called after NodeStageVolume
102+
// - path where volume is published if NodeExpandVolume is called after NodePublishVolume
103+
// DEPRECATION NOTICE: in future NodeExpandVolume will be always called after NodePublish
100104
volumePath string
101105
stagingTargetPath string
102106
fsType string
@@ -260,10 +264,10 @@ func (c *csiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOp
260264
return opts.newSize, fmt.Errorf("version of CSI driver does not support volume expansion")
261265
}
262266

263-
if opts.volumeid == "" {
267+
if opts.volumeID == "" {
264268
return opts.newSize, errors.New("missing volume id")
265269
}
266-
if opts.volumeid == "" {
270+
if opts.volumePath == "" {
267271
return opts.newSize, errors.New("missing volume path")
268272
}
269273

@@ -278,7 +282,7 @@ func (c *csiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOp
278282
defer closer.Close()
279283

280284
req := &csipbv1.NodeExpandVolumeRequest{
281-
VolumeId: opts.volumeid,
285+
VolumeId: opts.volumeID,
282286
VolumePath: opts.volumePath,
283287
StagingTargetPath: opts.stagingTargetPath,
284288
CapacityRange: &csipbv1.CapacityRange{RequiredBytes: opts.newSize.Value()},

pkg/volume/csi/csi_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (c *fakeCsiDriverClient) NodeSupportsStageUnstage(ctx context.Context) (boo
287287
func (c *fakeCsiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOptions) (resource.Quantity, error) {
288288
c.t.Log("calling fake.NodeExpandVolume")
289289
req := &csipbv1.NodeExpandVolumeRequest{
290-
VolumeId: opts.volumeid,
290+
VolumeId: opts.volumeID,
291291
VolumePath: opts.volumePath,
292292
StagingTargetPath: opts.stagingTargetPath,
293293
CapacityRange: &csipbv1.CapacityRange{RequiredBytes: opts.newSize.Value()},
@@ -653,7 +653,7 @@ func TestNodeExpandVolume(t *testing.T) {
653653
return nodeClient, fakeCloser, nil
654654
},
655655
}
656-
opts := csiResizeOptions{volumeid: tc.volID, volumePath: tc.volumePath, newSize: tc.newSize}
656+
opts := csiResizeOptions{volumeID: tc.volID, volumePath: tc.volumePath, newSize: tc.newSize}
657657
_, err := client.NodeExpandVolume(context.Background(), opts)
658658
checkErr(t, tc.mustFail, err)
659659
if !tc.mustFail {

pkg/volume/csi/expander.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (c *csiPlugin) nodeExpandWithClient(
102102
opts := csiResizeOptions{
103103
volumePath: resizeOptions.DeviceMountPath,
104104
stagingTargetPath: resizeOptions.DeviceStagePath,
105-
volumeid: csiSource.VolumeHandle,
105+
volumeID: csiSource.VolumeHandle,
106106
newSize: resizeOptions.NewSize,
107107
fsType: csiSource.FSType,
108108
accessMode: api.ReadWriteOnce,

pkg/volume/local/local_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func TestMapUnmap(t *testing.T) {
375375
var devPath string
376376

377377
if customMapper, ok := mapper.(volume.CustomBlockVolumeMapper); ok {
378-
err = customMapper.SetUpDevice()
378+
_, err = customMapper.SetUpDevice()
379379
if err != nil {
380380
t.Errorf("Failed to SetUpDevice, err: %v", err)
381381
}

pkg/volume/testing/testing.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -956,46 +956,46 @@ func (fv *FakeVolume) TearDownAt(dir string) error {
956956
}
957957

958958
// Block volume support
959-
func (fv *FakeVolume) SetUpDevice() error {
959+
func (fv *FakeVolume) SetUpDevice() (string, error) {
960960
fv.Lock()
961961
defer fv.Unlock()
962962
if fv.VolName == TimeoutOnMountDeviceVolumeName {
963963
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
964-
return volumetypes.NewUncertainProgressError("mount failed")
964+
return "", volumetypes.NewUncertainProgressError("mount failed")
965965
}
966966
if fv.VolName == FailMountDeviceVolumeName {
967967
fv.DeviceMountState[fv.VolName] = deviceNotMounted
968-
return fmt.Errorf("error mapping disk: %s", fv.VolName)
968+
return "", fmt.Errorf("error mapping disk: %s", fv.VolName)
969969
}
970970

971971
if fv.VolName == TimeoutAndFailOnMountDeviceVolumeName {
972972
_, ok := fv.DeviceMountState[fv.VolName]
973973
if !ok {
974974
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
975-
return volumetypes.NewUncertainProgressError("timed out mounting error")
975+
return "", volumetypes.NewUncertainProgressError("timed out mounting error")
976976
}
977977
fv.DeviceMountState[fv.VolName] = deviceNotMounted
978-
return fmt.Errorf("error mapping disk: %s", fv.VolName)
978+
return "", fmt.Errorf("error mapping disk: %s", fv.VolName)
979979
}
980980

981981
if fv.VolName == SuccessAndTimeoutDeviceName {
982982
_, ok := fv.DeviceMountState[fv.VolName]
983983
if ok {
984984
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
985-
return volumetypes.NewUncertainProgressError("error mounting state")
985+
return "", volumetypes.NewUncertainProgressError("error mounting state")
986986
}
987987
}
988988
if fv.VolName == SuccessAndFailOnMountDeviceName {
989989
_, ok := fv.DeviceMountState[fv.VolName]
990990
if ok {
991-
return fmt.Errorf("error mapping disk: %s", fv.VolName)
991+
return "", fmt.Errorf("error mapping disk: %s", fv.VolName)
992992
}
993993
}
994994

995995
fv.DeviceMountState[fv.VolName] = deviceMounted
996996
fv.SetUpDeviceCallCount++
997997

998-
return nil
998+
return "", nil
999999
}
10001000

10011001
// Block volume support

pkg/volume/util/operationexecutor/operation_generator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,10 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
603603
return volumeToMount.GenerateError("MountVolume.MarkDeviceAsMounted failed", markDeviceMountedErr)
604604
}
605605

606+
// If volume expansion is performed after MountDevice but before SetUp then
607+
// deviceMountPath and deviceStagePath is going to be the same.
608+
// Deprecation: Calling NodeExpandVolume after NodeStage/MountDevice will be deprecated
609+
// in a future version of k8s.
606610
resizeOptions.DeviceMountPath = deviceMountPath
607611
resizeOptions.DeviceStagePath = deviceMountPath
608612
resizeOptions.CSIVolumePhase = volume.CSIVolumeStaged

pkg/volume/volume.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ type CustomBlockVolumeMapper interface {
174174
// For most in-tree plugins, attacher.Attach() and attacher.WaitForAttach()
175175
// will do necessary works.
176176
// This may be called more than once, so implementations must be idempotent.
177-
SetUpDevice() (string, error)
177+
// SetUpDevice returns stagingPath if device setup was successful
178+
SetUpDevice() (stagingPath string, err error)
178179

179180
// MapPodDevice maps the block device to a path and return the path.
180181
// Unique device path across kubelet node reboot is required to avoid
181182
// unexpected block volume destruction.
182183
// If empty string is returned, the path retuned by attacher.Attach() and
183184
// attacher.WaitForAttach() will be used.
184-
MapPodDevice() (string, error)
185+
MapPodDevice() (publishPath string, err error)
185186
}
186187

187188
// BlockVolumeUnmapper interface is an unmapper interface for block volume.

0 commit comments

Comments
 (0)