mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
rename volumeid to volumeID
This commit is contained in:
parent
75e13e370e
commit
69613da0ae
@ -277,7 +277,7 @@ func TestBlockMapperSetupDeviceError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log("created attachement ", attachID)
|
t.Log("created attachement ", attachID)
|
||||||
|
|
||||||
err = csiMapper.SetUpDevice()
|
stagingPath, err := csiMapper.SetUpDevice()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("mapper unexpectedly succeeded")
|
t.Fatal("mapper unexpectedly succeeded")
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ func TestBlockMapperSetupDeviceError(t *testing.T) {
|
|||||||
if _, err := os.Stat(devDir); err == nil {
|
if _, err := os.Stat(devDir); err == nil {
|
||||||
t.Errorf("volume publish device directory %s was not deleted", devDir)
|
t.Errorf("volume publish device directory %s was not deleted", devDir)
|
||||||
}
|
}
|
||||||
stagingPath := csiMapper.getStagingPath()
|
|
||||||
if _, err := os.Stat(stagingPath); err == nil {
|
if _, err := os.Stat(stagingPath); err == nil {
|
||||||
t.Errorf("volume staging path %s was not deleted", stagingPath)
|
t.Errorf("volume staging path %s was not deleted", stagingPath)
|
||||||
}
|
}
|
||||||
@ -474,12 +474,11 @@ func TestVolumeSetupTeardown(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log("created attachement ", attachID)
|
t.Log("created attachement ", attachID)
|
||||||
|
|
||||||
err = csiMapper.SetUpDevice()
|
stagingPath, err := csiMapper.SetUpDevice()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("mapper failed to SetupDevice: %v", err)
|
t.Fatalf("mapper failed to SetupDevice: %v", err)
|
||||||
}
|
}
|
||||||
// Check if NodeStageVolume staged to the right path
|
// Check if NodeStageVolume staged to the right path
|
||||||
stagingPath := csiMapper.getStagingPath()
|
|
||||||
svols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
|
svols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
|
||||||
svol, ok := svols[csiMapper.volumeID]
|
svol, ok := svols[csiMapper.volumeID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -96,7 +96,11 @@ type csiDriverClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type csiResizeOptions struct {
|
type csiResizeOptions struct {
|
||||||
volumeid string
|
volumeID string
|
||||||
|
// volumePath is path where volume is available. It could be:
|
||||||
|
// - path where node is staged if NodeExpandVolume is called after NodeStageVolume
|
||||||
|
// - path where volume is published if NodeExpandVolume is called after NodePublishVolume
|
||||||
|
// DEPRECATION NOTICE: in future NodeExpandVolume will be always called after NodePublish
|
||||||
volumePath string
|
volumePath string
|
||||||
stagingTargetPath string
|
stagingTargetPath string
|
||||||
fsType string
|
fsType string
|
||||||
@ -260,10 +264,10 @@ func (c *csiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOp
|
|||||||
return opts.newSize, fmt.Errorf("version of CSI driver does not support volume expansion")
|
return opts.newSize, fmt.Errorf("version of CSI driver does not support volume expansion")
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.volumeid == "" {
|
if opts.volumeID == "" {
|
||||||
return opts.newSize, errors.New("missing volume id")
|
return opts.newSize, errors.New("missing volume id")
|
||||||
}
|
}
|
||||||
if opts.volumeid == "" {
|
if opts.volumePath == "" {
|
||||||
return opts.newSize, errors.New("missing volume path")
|
return opts.newSize, errors.New("missing volume path")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +282,7 @@ func (c *csiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOp
|
|||||||
defer closer.Close()
|
defer closer.Close()
|
||||||
|
|
||||||
req := &csipbv1.NodeExpandVolumeRequest{
|
req := &csipbv1.NodeExpandVolumeRequest{
|
||||||
VolumeId: opts.volumeid,
|
VolumeId: opts.volumeID,
|
||||||
VolumePath: opts.volumePath,
|
VolumePath: opts.volumePath,
|
||||||
StagingTargetPath: opts.stagingTargetPath,
|
StagingTargetPath: opts.stagingTargetPath,
|
||||||
CapacityRange: &csipbv1.CapacityRange{RequiredBytes: opts.newSize.Value()},
|
CapacityRange: &csipbv1.CapacityRange{RequiredBytes: opts.newSize.Value()},
|
||||||
|
@ -287,7 +287,7 @@ func (c *fakeCsiDriverClient) NodeSupportsStageUnstage(ctx context.Context) (boo
|
|||||||
func (c *fakeCsiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOptions) (resource.Quantity, error) {
|
func (c *fakeCsiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOptions) (resource.Quantity, error) {
|
||||||
c.t.Log("calling fake.NodeExpandVolume")
|
c.t.Log("calling fake.NodeExpandVolume")
|
||||||
req := &csipbv1.NodeExpandVolumeRequest{
|
req := &csipbv1.NodeExpandVolumeRequest{
|
||||||
VolumeId: opts.volumeid,
|
VolumeId: opts.volumeID,
|
||||||
VolumePath: opts.volumePath,
|
VolumePath: opts.volumePath,
|
||||||
StagingTargetPath: opts.stagingTargetPath,
|
StagingTargetPath: opts.stagingTargetPath,
|
||||||
CapacityRange: &csipbv1.CapacityRange{RequiredBytes: opts.newSize.Value()},
|
CapacityRange: &csipbv1.CapacityRange{RequiredBytes: opts.newSize.Value()},
|
||||||
@ -653,7 +653,7 @@ func TestNodeExpandVolume(t *testing.T) {
|
|||||||
return nodeClient, fakeCloser, nil
|
return nodeClient, fakeCloser, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
opts := csiResizeOptions{volumeid: tc.volID, volumePath: tc.volumePath, newSize: tc.newSize}
|
opts := csiResizeOptions{volumeID: tc.volID, volumePath: tc.volumePath, newSize: tc.newSize}
|
||||||
_, err := client.NodeExpandVolume(context.Background(), opts)
|
_, err := client.NodeExpandVolume(context.Background(), opts)
|
||||||
checkErr(t, tc.mustFail, err)
|
checkErr(t, tc.mustFail, err)
|
||||||
if !tc.mustFail {
|
if !tc.mustFail {
|
||||||
|
@ -102,7 +102,7 @@ func (c *csiPlugin) nodeExpandWithClient(
|
|||||||
opts := csiResizeOptions{
|
opts := csiResizeOptions{
|
||||||
volumePath: resizeOptions.DeviceMountPath,
|
volumePath: resizeOptions.DeviceMountPath,
|
||||||
stagingTargetPath: resizeOptions.DeviceStagePath,
|
stagingTargetPath: resizeOptions.DeviceStagePath,
|
||||||
volumeid: csiSource.VolumeHandle,
|
volumeID: csiSource.VolumeHandle,
|
||||||
newSize: resizeOptions.NewSize,
|
newSize: resizeOptions.NewSize,
|
||||||
fsType: csiSource.FSType,
|
fsType: csiSource.FSType,
|
||||||
accessMode: api.ReadWriteOnce,
|
accessMode: api.ReadWriteOnce,
|
||||||
|
@ -375,7 +375,7 @@ func TestMapUnmap(t *testing.T) {
|
|||||||
var devPath string
|
var devPath string
|
||||||
|
|
||||||
if customMapper, ok := mapper.(volume.CustomBlockVolumeMapper); ok {
|
if customMapper, ok := mapper.(volume.CustomBlockVolumeMapper); ok {
|
||||||
err = customMapper.SetUpDevice()
|
_, err = customMapper.SetUpDevice()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to SetUpDevice, err: %v", err)
|
t.Errorf("Failed to SetUpDevice, err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -956,46 +956,46 @@ func (fv *FakeVolume) TearDownAt(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Block volume support
|
// Block volume support
|
||||||
func (fv *FakeVolume) SetUpDevice() error {
|
func (fv *FakeVolume) SetUpDevice() (string, error) {
|
||||||
fv.Lock()
|
fv.Lock()
|
||||||
defer fv.Unlock()
|
defer fv.Unlock()
|
||||||
if fv.VolName == TimeoutOnMountDeviceVolumeName {
|
if fv.VolName == TimeoutOnMountDeviceVolumeName {
|
||||||
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
|
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
|
||||||
return volumetypes.NewUncertainProgressError("mount failed")
|
return "", volumetypes.NewUncertainProgressError("mount failed")
|
||||||
}
|
}
|
||||||
if fv.VolName == FailMountDeviceVolumeName {
|
if fv.VolName == FailMountDeviceVolumeName {
|
||||||
fv.DeviceMountState[fv.VolName] = deviceNotMounted
|
fv.DeviceMountState[fv.VolName] = deviceNotMounted
|
||||||
return fmt.Errorf("error mapping disk: %s", fv.VolName)
|
return "", fmt.Errorf("error mapping disk: %s", fv.VolName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fv.VolName == TimeoutAndFailOnMountDeviceVolumeName {
|
if fv.VolName == TimeoutAndFailOnMountDeviceVolumeName {
|
||||||
_, ok := fv.DeviceMountState[fv.VolName]
|
_, ok := fv.DeviceMountState[fv.VolName]
|
||||||
if !ok {
|
if !ok {
|
||||||
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
|
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
|
||||||
return volumetypes.NewUncertainProgressError("timed out mounting error")
|
return "", volumetypes.NewUncertainProgressError("timed out mounting error")
|
||||||
}
|
}
|
||||||
fv.DeviceMountState[fv.VolName] = deviceNotMounted
|
fv.DeviceMountState[fv.VolName] = deviceNotMounted
|
||||||
return fmt.Errorf("error mapping disk: %s", fv.VolName)
|
return "", fmt.Errorf("error mapping disk: %s", fv.VolName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fv.VolName == SuccessAndTimeoutDeviceName {
|
if fv.VolName == SuccessAndTimeoutDeviceName {
|
||||||
_, ok := fv.DeviceMountState[fv.VolName]
|
_, ok := fv.DeviceMountState[fv.VolName]
|
||||||
if ok {
|
if ok {
|
||||||
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
|
fv.DeviceMountState[fv.VolName] = deviceMountUncertain
|
||||||
return volumetypes.NewUncertainProgressError("error mounting state")
|
return "", volumetypes.NewUncertainProgressError("error mounting state")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fv.VolName == SuccessAndFailOnMountDeviceName {
|
if fv.VolName == SuccessAndFailOnMountDeviceName {
|
||||||
_, ok := fv.DeviceMountState[fv.VolName]
|
_, ok := fv.DeviceMountState[fv.VolName]
|
||||||
if ok {
|
if ok {
|
||||||
return fmt.Errorf("error mapping disk: %s", fv.VolName)
|
return "", fmt.Errorf("error mapping disk: %s", fv.VolName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fv.DeviceMountState[fv.VolName] = deviceMounted
|
fv.DeviceMountState[fv.VolName] = deviceMounted
|
||||||
fv.SetUpDeviceCallCount++
|
fv.SetUpDeviceCallCount++
|
||||||
|
|
||||||
return nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block volume support
|
// Block volume support
|
||||||
|
@ -603,6 +603,10 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
|
|||||||
return volumeToMount.GenerateError("MountVolume.MarkDeviceAsMounted failed", markDeviceMountedErr)
|
return volumeToMount.GenerateError("MountVolume.MarkDeviceAsMounted failed", markDeviceMountedErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If volume expansion is performed after MountDevice but before SetUp then
|
||||||
|
// deviceMountPath and deviceStagePath is going to be the same.
|
||||||
|
// Deprecation: Calling NodeExpandVolume after NodeStage/MountDevice will be deprecated
|
||||||
|
// in a future version of k8s.
|
||||||
resizeOptions.DeviceMountPath = deviceMountPath
|
resizeOptions.DeviceMountPath = deviceMountPath
|
||||||
resizeOptions.DeviceStagePath = deviceMountPath
|
resizeOptions.DeviceStagePath = deviceMountPath
|
||||||
resizeOptions.CSIVolumePhase = volume.CSIVolumeStaged
|
resizeOptions.CSIVolumePhase = volume.CSIVolumeStaged
|
||||||
|
@ -174,14 +174,15 @@ type CustomBlockVolumeMapper interface {
|
|||||||
// For most in-tree plugins, attacher.Attach() and attacher.WaitForAttach()
|
// For most in-tree plugins, attacher.Attach() and attacher.WaitForAttach()
|
||||||
// will do necessary works.
|
// will do necessary works.
|
||||||
// This may be called more than once, so implementations must be idempotent.
|
// This may be called more than once, so implementations must be idempotent.
|
||||||
SetUpDevice() (string, error)
|
// SetUpDevice returns stagingPath if device setup was successful
|
||||||
|
SetUpDevice() (stagingPath string, err error)
|
||||||
|
|
||||||
// MapPodDevice maps the block device to a path and return the path.
|
// MapPodDevice maps the block device to a path and return the path.
|
||||||
// Unique device path across kubelet node reboot is required to avoid
|
// Unique device path across kubelet node reboot is required to avoid
|
||||||
// unexpected block volume destruction.
|
// unexpected block volume destruction.
|
||||||
// If empty string is returned, the path retuned by attacher.Attach() and
|
// If empty string is returned, the path retuned by attacher.Attach() and
|
||||||
// attacher.WaitForAttach() will be used.
|
// attacher.WaitForAttach() will be used.
|
||||||
MapPodDevice() (string, error)
|
MapPodDevice() (publishPath string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockVolumeUnmapper interface is an unmapper interface for block volume.
|
// BlockVolumeUnmapper interface is an unmapper interface for block volume.
|
||||||
|
Loading…
Reference in New Issue
Block a user