From 81e360d20fbe7f734d33289c83b07ceddc9657db Mon Sep 17 00:00:00 2001 From: NickrenREN Date: Wed, 1 Aug 2018 21:00:45 +0800 Subject: [PATCH] update volume plugins accordingly --- .../volume/attachdetach/testing/testvolumespec.go | 8 ++++++++ pkg/volume/aws_ebs/attacher.go | 14 ++++++++++++++ pkg/volume/azure_dd/attacher.go | 3 +++ pkg/volume/azure_dd/azure_dd.go | 9 +++++++++ pkg/volume/cinder/attacher.go | 14 ++++++++++++++ pkg/volume/csi/csi_attacher.go | 4 ++++ pkg/volume/csi/csi_plugin.go | 10 ++++++++++ pkg/volume/fc/attacher.go | 14 ++++++++++++++ pkg/volume/flexvolume/attacher.go | 2 ++ pkg/volume/flexvolume/detacher.go | 2 ++ pkg/volume/flexvolume/plugin.go | 10 ++++++++++ pkg/volume/gce_pd/attacher.go | 14 ++++++++++++++ pkg/volume/iscsi/attacher.go | 14 ++++++++++++++ pkg/volume/photon_pd/attacher.go | 15 +++++++++++++++ pkg/volume/rbd/attacher.go | 14 ++++++++++++++ pkg/volume/rbd/rbd.go | 1 + pkg/volume/testing/testing.go | 9 +++++++++ pkg/volume/vsphere_volume/attacher.go | 15 +++++++++++++++ 18 files changed, 172 insertions(+) diff --git a/pkg/controller/volume/attachdetach/testing/testvolumespec.go b/pkg/controller/volume/attachdetach/testing/testvolumespec.go index d72fbe4e6ca..7dceaba2732 100644 --- a/pkg/controller/volume/attachdetach/testing/testvolumespec.go +++ b/pkg/controller/volume/attachdetach/testing/testvolumespec.go @@ -294,6 +294,10 @@ func (plugin *TestPlugin) NewAttacher() (volume.Attacher, error) { return &attacher, nil } +func (plugin *TestPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *TestPlugin) NewDetacher() (volume.Detacher, error) { detacher := testPluginDetacher{ detachedVolumeMap: plugin.detachedVolumeMap, @@ -302,6 +306,10 @@ func (plugin *TestPlugin) NewDetacher() (volume.Detacher, error) { return &detacher, nil } +func (plugin *TestPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (plugin *TestPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { return []string{}, nil } diff --git a/pkg/volume/aws_ebs/attacher.go b/pkg/volume/aws_ebs/attacher.go index e4178068dc0..da25691d41a 100644 --- a/pkg/volume/aws_ebs/attacher.go +++ b/pkg/volume/aws_ebs/attacher.go @@ -39,8 +39,12 @@ type awsElasticBlockStoreAttacher struct { var _ volume.Attacher = &awsElasticBlockStoreAttacher{} +var _ volume.DeviceMounter = &awsElasticBlockStoreAttacher{} + var _ volume.AttachableVolumePlugin = &awsElasticBlockStorePlugin{} +var _ volume.DeviceMountableVolumePlugin = &awsElasticBlockStorePlugin{} + func (plugin *awsElasticBlockStorePlugin) NewAttacher() (volume.Attacher, error) { awsCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -53,6 +57,10 @@ func (plugin *awsElasticBlockStorePlugin) NewAttacher() (volume.Attacher, error) }, nil } +func (plugin *awsElasticBlockStorePlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *awsElasticBlockStorePlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { mounter := plugin.host.GetMounter(plugin.GetPluginName()) return mounter.GetMountRefs(deviceMountPath) @@ -236,6 +244,8 @@ type awsElasticBlockStoreDetacher struct { var _ volume.Detacher = &awsElasticBlockStoreDetacher{} +var _ volume.DeviceUnmounter = &awsElasticBlockStoreDetacher{} + func (plugin *awsElasticBlockStorePlugin) NewDetacher() (volume.Detacher, error) { awsCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -248,6 +258,10 @@ func (plugin *awsElasticBlockStorePlugin) NewDetacher() (volume.Detacher, error) }, nil } +func (plugin *awsElasticBlockStorePlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (detacher *awsElasticBlockStoreDetacher) Detach(volumeName string, nodeName types.NodeName) error { volumeID := aws.KubernetesVolumeID(path.Base(volumeName)) diff --git a/pkg/volume/azure_dd/attacher.go b/pkg/volume/azure_dd/attacher.go index 2a76ef09c2f..556496b24ab 100644 --- a/pkg/volume/azure_dd/attacher.go +++ b/pkg/volume/azure_dd/attacher.go @@ -52,6 +52,9 @@ type azureDiskAttacher struct { var _ volume.Attacher = &azureDiskAttacher{} var _ volume.Detacher = &azureDiskDetacher{} +var _ volume.DeviceMounter = &azureDiskAttacher{} +var _ volume.DeviceUnmounter = &azureDiskDetacher{} + // acquire lock to get an lun number var getLunMutex = keymutex.NewKeyMutex() diff --git a/pkg/volume/azure_dd/azure_dd.go b/pkg/volume/azure_dd/azure_dd.go index 05e2f4fc46f..5969d408f0a 100644 --- a/pkg/volume/azure_dd/azure_dd.go +++ b/pkg/volume/azure_dd/azure_dd.go @@ -71,6 +71,7 @@ var _ volume.ProvisionableVolumePlugin = &azureDataDiskPlugin{} var _ volume.AttachableVolumePlugin = &azureDataDiskPlugin{} var _ volume.VolumePluginWithAttachLimits = &azureDataDiskPlugin{} var _ volume.ExpandableVolumePlugin = &azureDataDiskPlugin{} +var _ volume.DeviceMountableVolumePlugin = &azureDataDiskPlugin{} const ( azureDataDiskPluginName = "kubernetes.io/azure-disk" @@ -268,3 +269,11 @@ func (plugin *azureDataDiskPlugin) GetDeviceMountRefs(deviceMountPath string) ([ m := plugin.host.GetMounter(plugin.GetPluginName()) return m.GetMountRefs(deviceMountPath) } + +func (plugin *azureDataDiskPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + +func (plugin *azureDataDiskPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} diff --git a/pkg/volume/cinder/attacher.go b/pkg/volume/cinder/attacher.go index e6509543287..2cdc6da7a58 100644 --- a/pkg/volume/cinder/attacher.go +++ b/pkg/volume/cinder/attacher.go @@ -40,8 +40,12 @@ type cinderDiskAttacher struct { var _ volume.Attacher = &cinderDiskAttacher{} +var _ volume.DeviceMounter = &cinderDiskAttacher{} + var _ volume.AttachableVolumePlugin = &cinderPlugin{} +var _ volume.DeviceMountableVolumePlugin = &cinderPlugin{} + const ( probeVolumeInitDelay = 1 * time.Second probeVolumeFactor = 2.0 @@ -67,6 +71,10 @@ func (plugin *cinderPlugin) NewAttacher() (volume.Attacher, error) { }, nil } +func (plugin *cinderPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *cinderPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { mounter := plugin.host.GetMounter(plugin.GetPluginName()) return mounter.GetMountRefs(deviceMountPath) @@ -299,6 +307,8 @@ type cinderDiskDetacher struct { var _ volume.Detacher = &cinderDiskDetacher{} +var _ volume.DeviceUnmounter = &cinderDiskDetacher{} + func (plugin *cinderPlugin) NewDetacher() (volume.Detacher, error) { cinder, err := plugin.getCloudProvider() if err != nil { @@ -310,6 +320,10 @@ func (plugin *cinderPlugin) NewDetacher() (volume.Detacher, error) { }, nil } +func (plugin *cinderPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (detacher *cinderDiskDetacher) waitOperationFinished(volumeID string) error { backoff := wait.Backoff{ Duration: operationFinishInitDelay, diff --git a/pkg/volume/csi/csi_attacher.go b/pkg/volume/csi/csi_attacher.go index 1709bbac0f8..8e32330b254 100644 --- a/pkg/volume/csi/csi_attacher.go +++ b/pkg/volume/csi/csi_attacher.go @@ -56,6 +56,8 @@ type csiAttacher struct { // volume.Attacher methods var _ volume.Attacher = &csiAttacher{} +var _ volume.DeviceMounter = &csiAttacher{} + func (c *csiAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string, error) { if spec == nil { glog.Error(log("attacher.Attach missing volume.Spec")) @@ -373,6 +375,8 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo var _ volume.Detacher = &csiAttacher{} +var _ volume.DeviceUnmounter = &csiAttacher{} + func (c *csiAttacher) Detach(volumeName string, nodeName types.NodeName) error { // volumeName in format driverNamevolumeHandle generated by plugin.GetVolumeName() if volumeName == "" { diff --git a/pkg/volume/csi/csi_plugin.go b/pkg/volume/csi/csi_plugin.go index 5eba4f79c4b..7f82b8249ac 100644 --- a/pkg/volume/csi/csi_plugin.go +++ b/pkg/volume/csi/csi_plugin.go @@ -280,6 +280,8 @@ func (p *csiPlugin) SupportsBulkVolumeVerification() bool { // volume.AttachableVolumePlugin methods var _ volume.AttachableVolumePlugin = &csiPlugin{} +var _ volume.DeviceMountableVolumePlugin = &csiPlugin{} + func (p *csiPlugin) NewAttacher() (volume.Attacher, error) { k8s := p.host.GetKubeClient() if k8s == nil { @@ -294,6 +296,10 @@ func (p *csiPlugin) NewAttacher() (volume.Attacher, error) { }, nil } +func (p *csiPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return p.NewAttacher() +} + func (p *csiPlugin) NewDetacher() (volume.Detacher, error) { k8s := p.host.GetKubeClient() if k8s == nil { @@ -308,6 +314,10 @@ func (p *csiPlugin) NewDetacher() (volume.Detacher, error) { }, nil } +func (p *csiPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return p.NewDetacher() +} + func (p *csiPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { m := p.host.GetMounter(p.GetPluginName()) return m.GetMountRefs(deviceMountPath) diff --git a/pkg/volume/fc/attacher.go b/pkg/volume/fc/attacher.go index 69d14fbff10..7030a949993 100644 --- a/pkg/volume/fc/attacher.go +++ b/pkg/volume/fc/attacher.go @@ -40,8 +40,12 @@ type fcAttacher struct { var _ volume.Attacher = &fcAttacher{} +var _ volume.DeviceMounter = &fcAttacher{} + var _ volume.AttachableVolumePlugin = &fcPlugin{} +var _ volume.DeviceMountableVolumePlugin = &fcPlugin{} + func (plugin *fcPlugin) NewAttacher() (volume.Attacher, error) { return &fcAttacher{ host: plugin.host, @@ -49,6 +53,10 @@ func (plugin *fcPlugin) NewAttacher() (volume.Attacher, error) { }, nil } +func (plugin *fcPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *fcPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { mounter := plugin.host.GetMounter(plugin.GetPluginName()) return mounter.GetMountRefs(deviceMountPath) @@ -129,6 +137,8 @@ type fcDetacher struct { var _ volume.Detacher = &fcDetacher{} +var _ volume.DeviceUnmounter = &fcDetacher{} + func (plugin *fcPlugin) NewDetacher() (volume.Detacher, error) { return &fcDetacher{ mounter: plugin.host.GetMounter(plugin.GetPluginName()), @@ -136,6 +146,10 @@ func (plugin *fcPlugin) NewDetacher() (volume.Detacher, error) { }, nil } +func (plugin *fcPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (detacher *fcDetacher) Detach(volumeName string, nodeName types.NodeName) error { return nil } diff --git a/pkg/volume/flexvolume/attacher.go b/pkg/volume/flexvolume/attacher.go index 2464b3f2392..f7767d38948 100644 --- a/pkg/volume/flexvolume/attacher.go +++ b/pkg/volume/flexvolume/attacher.go @@ -31,6 +31,8 @@ type flexVolumeAttacher struct { var _ volume.Attacher = &flexVolumeAttacher{} +var _ volume.DeviceMounter = &flexVolumeAttacher{} + // Attach is part of the volume.Attacher interface func (a *flexVolumeAttacher) Attach(spec *volume.Spec, hostName types.NodeName) (string, error) { diff --git a/pkg/volume/flexvolume/detacher.go b/pkg/volume/flexvolume/detacher.go index c55ffbfa473..03be4a15f0d 100644 --- a/pkg/volume/flexvolume/detacher.go +++ b/pkg/volume/flexvolume/detacher.go @@ -32,6 +32,8 @@ type flexVolumeDetacher struct { var _ volume.Detacher = &flexVolumeDetacher{} +var _ volume.DeviceUnmounter = &flexVolumeDetacher{} + // Detach is part of the volume.Detacher interface. func (d *flexVolumeDetacher) Detach(volumeName string, hostName types.NodeName) error { diff --git a/pkg/volume/flexvolume/plugin.go b/pkg/volume/flexvolume/plugin.go index e67318bc85b..70d4b009f6f 100644 --- a/pkg/volume/flexvolume/plugin.go +++ b/pkg/volume/flexvolume/plugin.go @@ -58,6 +58,8 @@ type flexVolumeAttachablePlugin struct { var _ volume.AttachableVolumePlugin = &flexVolumeAttachablePlugin{} var _ volume.PersistentVolumePlugin = &flexVolumePlugin{} +var _ volume.DeviceMountableVolumePlugin = &flexVolumeAttachablePlugin{} + type PluginFactory interface { NewFlexVolumePlugin(pluginDir, driverName string, runner exec.Interface) (volume.VolumePlugin, error) } @@ -218,11 +220,19 @@ func (plugin *flexVolumeAttachablePlugin) NewAttacher() (volume.Attacher, error) return &flexVolumeAttacher{plugin}, nil } +func (plugin *flexVolumeAttachablePlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + // NewDetacher is part of the volume.AttachableVolumePlugin interface. func (plugin *flexVolumeAttachablePlugin) NewDetacher() (volume.Detacher, error) { return &flexVolumeDetacher{plugin}, nil } +func (plugin *flexVolumeAttachablePlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + // ConstructVolumeSpec is part of the volume.AttachableVolumePlugin interface. func (plugin *flexVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) { flexVolume := &api.Volume{ diff --git a/pkg/volume/gce_pd/attacher.go b/pkg/volume/gce_pd/attacher.go index 8a6256b617f..391cc8641cb 100644 --- a/pkg/volume/gce_pd/attacher.go +++ b/pkg/volume/gce_pd/attacher.go @@ -40,8 +40,12 @@ type gcePersistentDiskAttacher struct { var _ volume.Attacher = &gcePersistentDiskAttacher{} +var _ volume.DeviceMounter = &gcePersistentDiskAttacher{} + var _ volume.AttachableVolumePlugin = &gcePersistentDiskPlugin{} +var _ volume.DeviceMountableVolumePlugin = &gcePersistentDiskPlugin{} + func (plugin *gcePersistentDiskPlugin) NewAttacher() (volume.Attacher, error) { gceCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -54,6 +58,10 @@ func (plugin *gcePersistentDiskPlugin) NewAttacher() (volume.Attacher, error) { }, nil } +func (plugin *gcePersistentDiskPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *gcePersistentDiskPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { mounter := plugin.host.GetMounter(plugin.GetPluginName()) return mounter.GetMountRefs(deviceMountPath) @@ -226,6 +234,8 @@ type gcePersistentDiskDetacher struct { var _ volume.Detacher = &gcePersistentDiskDetacher{} +var _ volume.DeviceUnmounter = &gcePersistentDiskDetacher{} + func (plugin *gcePersistentDiskPlugin) NewDetacher() (volume.Detacher, error) { gceCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -238,6 +248,10 @@ func (plugin *gcePersistentDiskPlugin) NewDetacher() (volume.Detacher, error) { }, nil } +func (plugin *gcePersistentDiskPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + // Detach checks with the GCE cloud provider if the specified volume is already // attached to the specified node. If the volume is not attached, it succeeds // (returns nil). If it is attached, Detach issues a call to the GCE cloud diff --git a/pkg/volume/iscsi/attacher.go b/pkg/volume/iscsi/attacher.go index d7fa9eb9ecc..82eccfd3d29 100644 --- a/pkg/volume/iscsi/attacher.go +++ b/pkg/volume/iscsi/attacher.go @@ -40,8 +40,12 @@ type iscsiAttacher struct { var _ volume.Attacher = &iscsiAttacher{} +var _ volume.DeviceMounter = &iscsiAttacher{} + var _ volume.AttachableVolumePlugin = &iscsiPlugin{} +var _ volume.DeviceMountableVolumePlugin = &iscsiPlugin{} + func (plugin *iscsiPlugin) NewAttacher() (volume.Attacher, error) { return &iscsiAttacher{ host: plugin.host, @@ -50,6 +54,10 @@ func (plugin *iscsiPlugin) NewAttacher() (volume.Attacher, error) { }, nil } +func (plugin *iscsiPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *iscsiPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) { mounter := plugin.host.GetMounter(iscsiPluginName) return mounter.GetMountRefs(deviceMountPath) @@ -133,6 +141,8 @@ type iscsiDetacher struct { var _ volume.Detacher = &iscsiDetacher{} +var _ volume.DeviceUnmounter = &iscsiDetacher{} + func (plugin *iscsiPlugin) NewDetacher() (volume.Detacher, error) { return &iscsiDetacher{ host: plugin.host, @@ -141,6 +151,10 @@ func (plugin *iscsiPlugin) NewDetacher() (volume.Detacher, error) { }, nil } +func (plugin *iscsiPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (detacher *iscsiDetacher) Detach(volumeName string, nodeName types.NodeName) error { return nil } diff --git a/pkg/volume/photon_pd/attacher.go b/pkg/volume/photon_pd/attacher.go index 368b9bea94f..016fd65b839 100644 --- a/pkg/volume/photon_pd/attacher.go +++ b/pkg/volume/photon_pd/attacher.go @@ -40,8 +40,13 @@ type photonPersistentDiskAttacher struct { } var _ volume.Attacher = &photonPersistentDiskAttacher{} + +var _ volume.DeviceMounter = &photonPersistentDiskAttacher{} + var _ volume.AttachableVolumePlugin = &photonPersistentDiskPlugin{} +var _ volume.DeviceMountableVolumePlugin = &photonPersistentDiskPlugin{} + func (plugin *photonPersistentDiskPlugin) NewAttacher() (volume.Attacher, error) { photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -55,6 +60,10 @@ func (plugin *photonPersistentDiskPlugin) NewAttacher() (volume.Attacher, error) }, nil } +func (plugin *photonPersistentDiskPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + // Attaches the volume specified by the given spec to the given host. // On success, returns the device path where the device was attached on the // node. @@ -229,6 +238,8 @@ type photonPersistentDiskDetacher struct { var _ volume.Detacher = &photonPersistentDiskDetacher{} +var _ volume.DeviceUnmounter = &photonPersistentDiskDetacher{} + func (plugin *photonPersistentDiskPlugin) NewDetacher() (volume.Detacher, error) { photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -242,6 +253,10 @@ func (plugin *photonPersistentDiskPlugin) NewDetacher() (volume.Detacher, error) }, nil } +func (plugin *photonPersistentDiskPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + // Detach the given device from the given host. func (detacher *photonPersistentDiskDetacher) Detach(volumeName string, nodeName types.NodeName) error { diff --git a/pkg/volume/rbd/attacher.go b/pkg/volume/rbd/attacher.go index 628f985ecc9..70fc15ea618 100644 --- a/pkg/volume/rbd/attacher.go +++ b/pkg/volume/rbd/attacher.go @@ -34,6 +34,11 @@ func (plugin *rbdPlugin) NewAttacher() (volume.Attacher, error) { return plugin.newAttacherInternal(&RBDUtil{}) } +// NewDeviceMounter implements DeviceMountableVolumePlugin.NewDeviceMounter +func (plugin *rbdPlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *rbdPlugin) newAttacherInternal(manager diskManager) (volume.Attacher, error) { return &rbdAttacher{ plugin: plugin, @@ -47,6 +52,11 @@ func (plugin *rbdPlugin) NewDetacher() (volume.Detacher, error) { return plugin.newDetacherInternal(&RBDUtil{}) } +// NewDeviceUnmounter implements DeviceMountableVolumePlugin.NewDeviceUnmounter +func (plugin *rbdPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (plugin *rbdPlugin) newDetacherInternal(manager diskManager) (volume.Detacher, error) { return &rbdDetacher{ plugin: plugin, @@ -70,6 +80,8 @@ type rbdAttacher struct { var _ volume.Attacher = &rbdAttacher{} +var _ volume.DeviceMounter = &rbdAttacher{} + // Attach implements Attacher.Attach. // We do not lock image here, because it requires kube-controller-manager to // access external `rbd` utility. And there is no need since AttachDetach @@ -172,6 +184,8 @@ type rbdDetacher struct { var _ volume.Detacher = &rbdDetacher{} +var _ volume.DeviceUnmounter = &rbdDetacher{} + // UnmountDevice implements Detacher.UnmountDevice. It unmounts the global // mount of the RBD image. This is called once all bind mounts have been // unmounted. diff --git a/pkg/volume/rbd/rbd.go b/pkg/volume/rbd/rbd.go index 20776de47f6..b94e307ba97 100644 --- a/pkg/volume/rbd/rbd.go +++ b/pkg/volume/rbd/rbd.go @@ -61,6 +61,7 @@ var _ volume.ProvisionableVolumePlugin = &rbdPlugin{} var _ volume.AttachableVolumePlugin = &rbdPlugin{} var _ volume.ExpandableVolumePlugin = &rbdPlugin{} var _ volume.BlockVolumePlugin = &rbdPlugin{} +var _ volume.DeviceMountableVolumePlugin = &rbdPlugin{} const ( rbdPluginName = "kubernetes.io/rbd" diff --git a/pkg/volume/testing/testing.go b/pkg/volume/testing/testing.go index 17aa4106351..cacbcb3ca3c 100644 --- a/pkg/volume/testing/testing.go +++ b/pkg/volume/testing/testing.go @@ -242,6 +242,7 @@ var _ DeletableVolumePlugin = &FakeVolumePlugin{} var _ ProvisionableVolumePlugin = &FakeVolumePlugin{} var _ AttachableVolumePlugin = &FakeVolumePlugin{} var _ VolumePluginWithAttachLimits = &FakeVolumePlugin{} +var _ DeviceMountableVolumePlugin = &FakeVolumePlugin{} func (plugin *FakeVolumePlugin) getFakeVolume(list *[]*FakeVolume) *FakeVolume { volume := &FakeVolume{} @@ -372,6 +373,10 @@ func (plugin *FakeVolumePlugin) NewAttacher() (Attacher, error) { return plugin.getFakeVolume(&plugin.Attachers), nil } +func (plugin *FakeVolumePlugin) NewDeviceMounter() (DeviceMounter, error) { + return plugin.NewAttacher() +} + func (plugin *FakeVolumePlugin) GetAttachers() (Attachers []*FakeVolume) { plugin.RLock() defer plugin.RUnlock() @@ -391,6 +396,10 @@ func (plugin *FakeVolumePlugin) NewDetacher() (Detacher, error) { return plugin.getFakeVolume(&plugin.Detachers), nil } +func (plugin *FakeVolumePlugin) NewDeviceUnmounter() (DeviceUnmounter, error) { + return plugin.NewDetacher() +} + func (plugin *FakeVolumePlugin) GetDetachers() (Detachers []*FakeVolume) { plugin.RLock() defer plugin.RUnlock() diff --git a/pkg/volume/vsphere_volume/attacher.go b/pkg/volume/vsphere_volume/attacher.go index ad6698de847..c49be010c3a 100644 --- a/pkg/volume/vsphere_volume/attacher.go +++ b/pkg/volume/vsphere_volume/attacher.go @@ -38,8 +38,13 @@ type vsphereVMDKAttacher struct { } var _ volume.Attacher = &vsphereVMDKAttacher{} + +var _ volume.DeviceMounter = &vsphereVMDKAttacher{} + var _ volume.AttachableVolumePlugin = &vsphereVolumePlugin{} +var _ volume.DeviceMountableVolumePlugin = &vsphereVolumePlugin{} + // Singleton key mutex for keeping attach operations for the same host atomic var attachdetachMutex = keymutex.NewKeyMutex() @@ -55,6 +60,10 @@ func (plugin *vsphereVolumePlugin) NewAttacher() (volume.Attacher, error) { }, nil } +func (plugin *vsphereVolumePlugin) NewDeviceMounter() (volume.DeviceMounter, error) { + return plugin.NewAttacher() +} + // Attaches the volume specified by the given spec to the given host. // On success, returns the device path where the device was attached on the // node. @@ -237,6 +246,8 @@ type vsphereVMDKDetacher struct { var _ volume.Detacher = &vsphereVMDKDetacher{} +var _ volume.DeviceUnmounter = &vsphereVMDKDetacher{} + func (plugin *vsphereVolumePlugin) NewDetacher() (volume.Detacher, error) { vsphereCloud, err := getCloudProvider(plugin.host.GetCloudProvider()) if err != nil { @@ -249,6 +260,10 @@ func (plugin *vsphereVolumePlugin) NewDetacher() (volume.Detacher, error) { }, nil } +func (plugin *vsphereVolumePlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) { + return plugin.NewDetacher() +} + // Detach the given device from the given node. func (detacher *vsphereVMDKDetacher) Detach(volumeName string, nodeName types.NodeName) error {