mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #10484 from markturansky/vol_iscsi_export
Changed ISCSI plugin name from exported to private
This commit is contained in:
commit
5f79267b97
@ -30,29 +30,29 @@ import (
|
|||||||
|
|
||||||
// This is the primary entrypoint for volume plugins.
|
// This is the primary entrypoint for volume plugins.
|
||||||
func ProbeVolumePlugins() []volume.VolumePlugin {
|
func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||||
return []volume.VolumePlugin{&ISCSIPlugin{nil, exec.New()}}
|
return []volume.VolumePlugin{&iscsiPlugin{nil, exec.New()}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ISCSIPlugin struct {
|
type iscsiPlugin struct {
|
||||||
host volume.VolumeHost
|
host volume.VolumeHost
|
||||||
exe exec.Interface
|
exe exec.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ volume.VolumePlugin = &ISCSIPlugin{}
|
var _ volume.VolumePlugin = &iscsiPlugin{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ISCSIPluginName = "kubernetes.io/iscsi"
|
iscsiPluginName = "kubernetes.io/iscsi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) Init(host volume.VolumeHost) {
|
func (plugin *iscsiPlugin) Init(host volume.VolumeHost) {
|
||||||
plugin.host = host
|
plugin.host = host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) Name() string {
|
func (plugin *iscsiPlugin) Name() string {
|
||||||
return ISCSIPluginName
|
return iscsiPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *iscsiPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if spec.VolumeSource.ISCSI == nil && spec.PersistentVolumeSource.ISCSI == nil {
|
if spec.VolumeSource.ISCSI == nil && spec.PersistentVolumeSource.ISCSI == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -67,19 +67,19 @@ func (plugin *ISCSIPlugin) CanSupport(spec *volume.Spec) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
|
func (plugin *iscsiPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
|
||||||
return []api.PersistentVolumeAccessMode{
|
return []api.PersistentVolumeAccessMode{
|
||||||
api.ReadWriteOnce,
|
api.ReadWriteOnce,
|
||||||
api.ReadOnlyMany,
|
api.ReadOnlyMany,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.VolumeOptions, mounter mount.Interface) (volume.Builder, error) {
|
func (plugin *iscsiPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.VolumeOptions, mounter mount.Interface) (volume.Builder, error) {
|
||||||
// Inject real implementations here, test through the internal function.
|
// Inject real implementations here, test through the internal function.
|
||||||
return plugin.newBuilderInternal(spec, pod.UID, &ISCSIUtil{}, mounter)
|
return plugin.newBuilderInternal(spec, pod.UID, &ISCSIUtil{}, mounter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Builder, error) {
|
func (plugin *iscsiPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Builder, error) {
|
||||||
var iscsi *api.ISCSIVolumeSource
|
var iscsi *api.ISCSIVolumeSource
|
||||||
if spec.VolumeSource.ISCSI != nil {
|
if spec.VolumeSource.ISCSI != nil {
|
||||||
iscsi = spec.VolumeSource.ISCSI
|
iscsi = spec.VolumeSource.ISCSI
|
||||||
@ -103,12 +103,12 @@ func (plugin *ISCSIPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UI
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) NewCleaner(volName string, podUID types.UID, mounter mount.Interface) (volume.Cleaner, error) {
|
func (plugin *iscsiPlugin) NewCleaner(volName string, podUID types.UID, mounter mount.Interface) (volume.Cleaner, error) {
|
||||||
// Inject real implementations here, test through the internal function.
|
// Inject real implementations here, test through the internal function.
|
||||||
return plugin.newCleanerInternal(volName, podUID, &ISCSIUtil{}, mounter)
|
return plugin.newCleanerInternal(volName, podUID, &ISCSIUtil{}, mounter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) newCleanerInternal(volName string, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Cleaner, error) {
|
func (plugin *iscsiPlugin) newCleanerInternal(volName string, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Cleaner, error) {
|
||||||
return &iscsiDisk{
|
return &iscsiDisk{
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
volName: volName,
|
volName: volName,
|
||||||
@ -118,7 +118,7 @@ func (plugin *ISCSIPlugin) newCleanerInternal(volName string, podUID types.UID,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *ISCSIPlugin) execCommand(command string, args []string) ([]byte, error) {
|
func (plugin *iscsiPlugin) execCommand(command string, args []string) ([]byte, error) {
|
||||||
cmd := plugin.exe.Command(command, args...)
|
cmd := plugin.exe.Command(command, args...)
|
||||||
return cmd.CombinedOutput()
|
return cmd.CombinedOutput()
|
||||||
}
|
}
|
||||||
@ -131,14 +131,14 @@ type iscsiDisk struct {
|
|||||||
readOnly bool
|
readOnly bool
|
||||||
lun string
|
lun string
|
||||||
fsType string
|
fsType string
|
||||||
plugin *ISCSIPlugin
|
plugin *iscsiPlugin
|
||||||
mounter mount.Interface
|
mounter mount.Interface
|
||||||
// Utility interface that provides API calls to the provider to attach/detach disks.
|
// Utility interface that provides API calls to the provider to attach/detach disks.
|
||||||
manager diskManager
|
manager diskManager
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iscsi *iscsiDisk) GetPath() string {
|
func (iscsi *iscsiDisk) GetPath() string {
|
||||||
name := ISCSIPluginName
|
name := iscsiPluginName
|
||||||
// safe to use PodVolumeDir now: volume teardown occurs before pod is cleaned up
|
// safe to use PodVolumeDir now: volume teardown occurs before pod is cleaned up
|
||||||
return iscsi.plugin.host.GetPodVolumeDir(iscsi.podUID, util.EscapeQualifiedNameForDisk(name), iscsi.volName)
|
return iscsi.plugin.host.GetPodVolumeDir(iscsi.podUID, util.EscapeQualifiedNameForDisk(name), iscsi.volName)
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
|
|||||||
}
|
}
|
||||||
fakeManager := &fakeDiskManager{}
|
fakeManager := &fakeDiskManager{}
|
||||||
fakeMounter := &mount.FakeMounter{}
|
fakeMounter := &mount.FakeMounter{}
|
||||||
builder, err := plug.(*ISCSIPlugin).newBuilderInternal(spec, types.UID("poduid"), fakeManager, fakeMounter)
|
builder, err := plug.(*iscsiPlugin).newBuilderInternal(spec, types.UID("poduid"), fakeManager, fakeMounter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to make a new Builder: %v", err)
|
t.Errorf("Failed to make a new Builder: %v", err)
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fakeManager = &fakeDiskManager{}
|
fakeManager = &fakeDiskManager{}
|
||||||
cleaner, err := plug.(*ISCSIPlugin).newCleanerInternal("vol1", types.UID("poduid"), fakeManager, fakeMounter)
|
cleaner, err := plug.(*iscsiPlugin).newCleanerInternal("vol1", types.UID("poduid"), fakeManager, fakeMounter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to make a new Cleaner: %v", err)
|
t.Errorf("Failed to make a new Cleaner: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ func getDevicePrefixRefCount(mounter mount.Interface, deviceNamePrefix string) (
|
|||||||
|
|
||||||
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/pod/iscsi/portal-iqn-some_iqn-lun-0
|
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/pod/iscsi/portal-iqn-some_iqn-lun-0
|
||||||
func makePDNameInternal(host volume.VolumeHost, portal string, iqn string, lun string) string {
|
func makePDNameInternal(host volume.VolumeHost, portal string, iqn string, lun string) string {
|
||||||
return path.Join(host.GetPluginDir(ISCSIPluginName), "iscsi", portal+"-iqn-"+iqn+"-lun-"+lun)
|
return path.Join(host.GetPluginDir(iscsiPluginName), "iscsi", portal+"-iqn-"+iqn+"-lun-"+lun)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ISCSIUtil struct{}
|
type ISCSIUtil struct{}
|
||||||
|
Loading…
Reference in New Issue
Block a user