mirror of https://github.com/k3s-io/k3s
Merge pull request #10485 from markturansky/volume_rbd_export
Changed RBD Volume plugin name from exported to privatepull/6/head
commit
2e3841efc5
|
@ -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{&RBDPlugin{nil, exec.New()}}
|
return []volume.VolumePlugin{&rbdPlugin{nil, exec.New()}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type RBDPlugin struct {
|
type rbdPlugin struct {
|
||||||
host volume.VolumeHost
|
host volume.VolumeHost
|
||||||
exe exec.Interface
|
exe exec.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ volume.VolumePlugin = &RBDPlugin{}
|
var _ volume.VolumePlugin = &rbdPlugin{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RBDPluginName = "kubernetes.io/rbd"
|
rbdPluginName = "kubernetes.io/rbd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (plugin *RBDPlugin) Init(host volume.VolumeHost) {
|
func (plugin *rbdPlugin) Init(host volume.VolumeHost) {
|
||||||
plugin.host = host
|
plugin.host = host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) Name() string {
|
func (plugin *rbdPlugin) Name() string {
|
||||||
return RBDPluginName
|
return rbdPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *rbdPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
if spec.VolumeSource.RBD == nil && spec.PersistentVolumeSource.RBD == nil {
|
if spec.VolumeSource.RBD == nil && spec.PersistentVolumeSource.RBD == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,14 @@ func (plugin *RBDPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
|
func (plugin *rbdPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
|
||||||
return []api.PersistentVolumeAccessMode{
|
return []api.PersistentVolumeAccessMode{
|
||||||
api.ReadWriteOnce,
|
api.ReadWriteOnce,
|
||||||
api.ReadOnlyMany,
|
api.ReadOnlyMany,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.VolumeOptions, mounter mount.Interface) (volume.Builder, error) {
|
func (plugin *rbdPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.VolumeOptions, mounter mount.Interface) (volume.Builder, error) {
|
||||||
secret := ""
|
secret := ""
|
||||||
source := plugin.getRBDVolumeSource(spec)
|
source := plugin.getRBDVolumeSource(spec)
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func (plugin *RBDPlugin) NewBuilder(spec *volume.Spec, pod *api.Pod, _ volume.Vo
|
||||||
return plugin.newBuilderInternal(spec, pod.UID, &RBDUtil{}, mounter, secret)
|
return plugin.newBuilderInternal(spec, pod.UID, &RBDUtil{}, mounter, secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) getRBDVolumeSource(spec *volume.Spec) *api.RBDVolumeSource {
|
func (plugin *rbdPlugin) getRBDVolumeSource(spec *volume.Spec) *api.RBDVolumeSource {
|
||||||
if spec.VolumeSource.RBD != nil {
|
if spec.VolumeSource.RBD != nil {
|
||||||
return spec.VolumeSource.RBD
|
return spec.VolumeSource.RBD
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,7 +105,7 @@ func (plugin *RBDPlugin) getRBDVolumeSource(spec *volume.Spec) *api.RBDVolumeSou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface, secret string) (volume.Builder, error) {
|
func (plugin *rbdPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface, secret string) (volume.Builder, error) {
|
||||||
source := plugin.getRBDVolumeSource(spec)
|
source := plugin.getRBDVolumeSource(spec)
|
||||||
pool := source.RBDPool
|
pool := source.RBDPool
|
||||||
if pool == "" {
|
if pool == "" {
|
||||||
|
@ -137,12 +137,12 @@ func (plugin *RBDPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) NewCleaner(volName string, podUID types.UID, mounter mount.Interface) (volume.Cleaner, error) {
|
func (plugin *rbdPlugin) 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, &RBDUtil{}, mounter)
|
return plugin.newCleanerInternal(volName, podUID, &RBDUtil{}, mounter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) newCleanerInternal(volName string, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Cleaner, error) {
|
func (plugin *rbdPlugin) newCleanerInternal(volName string, podUID types.UID, manager diskManager, mounter mount.Interface) (volume.Cleaner, error) {
|
||||||
return &rbd{
|
return &rbd{
|
||||||
podUID: podUID,
|
podUID: podUID,
|
||||||
volName: volName,
|
volName: volName,
|
||||||
|
@ -163,14 +163,14 @@ type rbd struct {
|
||||||
secret string
|
secret string
|
||||||
fsType string
|
fsType string
|
||||||
readOnly bool
|
readOnly bool
|
||||||
plugin *RBDPlugin
|
plugin *rbdPlugin
|
||||||
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 (rbd *rbd) GetPath() string {
|
func (rbd *rbd) GetPath() string {
|
||||||
name := RBDPluginName
|
name := rbdPluginName
|
||||||
// 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 rbd.plugin.host.GetPodVolumeDir(rbd.podUID, util.EscapeQualifiedNameForDisk(name), rbd.volName)
|
return rbd.plugin.host.GetPodVolumeDir(rbd.podUID, util.EscapeQualifiedNameForDisk(name), rbd.volName)
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ func (rbd *rbd) TearDownAt(dir string) error {
|
||||||
return diskTearDown(rbd.manager, *rbd, dir, rbd.mounter)
|
return diskTearDown(rbd.manager, *rbd, dir, rbd.mounter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *RBDPlugin) execCommand(command string, args []string) ([]byte, error) {
|
func (plugin *rbdPlugin) 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()
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Can't find the plugin by name")
|
t.Errorf("Can't find the plugin by name")
|
||||||
}
|
}
|
||||||
builder, err := plug.(*RBDPlugin).newBuilderInternal(spec, types.UID("poduid"), &fakeDiskManager{}, &mount.FakeMounter{}, "secrets")
|
builder, err := plug.(*rbdPlugin).newBuilderInternal(spec, types.UID("poduid"), &fakeDiskManager{}, &mount.FakeMounter{}, "secrets")
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleaner, err := plug.(*RBDPlugin).newCleanerInternal("vol1", types.UID("poduid"), &fakeDiskManager{}, &mount.FakeMounter{})
|
cleaner, err := plug.(*rbdPlugin).newCleanerInternal("vol1", types.UID("poduid"), &fakeDiskManager{}, &mount.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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ func waitForPathToExist(devicePath string, maxRetries int) bool {
|
||||||
|
|
||||||
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/pod/rbd/pool-image-image
|
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/pod/rbd/pool-image-image
|
||||||
func makePDNameInternal(host volume.VolumeHost, pool string, image string) string {
|
func makePDNameInternal(host volume.VolumeHost, pool string, image string) string {
|
||||||
return path.Join(host.GetPluginDir(RBDPluginName), "rbd", pool+"-image-"+image)
|
return path.Join(host.GetPluginDir(rbdPluginName), "rbd", pool+"-image-"+image)
|
||||||
}
|
}
|
||||||
|
|
||||||
type RBDUtil struct{}
|
type RBDUtil struct{}
|
||||||
|
|
Loading…
Reference in New Issue