mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #80973 from xiaoanyunfei/bugfix/orphan-volume
fix orphaned pod flexvolume can not be cleaned up
This commit is contained in:
commit
8d773421ee
@ -124,11 +124,11 @@ func TestCanSupport(t *testing.T) {
|
||||
runner := exec.New()
|
||||
installPluginUnderTest(t, "kubernetes.io", "fakeAttacher", tmpDir, execScriptTempl1, nil)
|
||||
plugMgr.InitPlugins(nil, GetDynamicPluginProber(tmpDir, runner), volumetest.NewFakeVolumeHost(t, "fake", nil, nil))
|
||||
plugin, err := plugMgr.FindPluginByName("flexvolume-kubernetes.io/fakeAttacher")
|
||||
plugin, err := plugMgr.FindPluginByName("kubernetes.io/fakeAttacher")
|
||||
if err != nil {
|
||||
t.Fatalf("Can't find the plugin by name")
|
||||
}
|
||||
if plugin.GetPluginName() != "flexvolume-kubernetes.io/fakeAttacher" {
|
||||
if plugin.GetPluginName() != "kubernetes.io/fakeAttacher" {
|
||||
t.Errorf("Wrong name: %s", plugin.GetPluginName())
|
||||
}
|
||||
if !plugin.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{FlexVolume: &v1.FlexVolumeSource{Driver: "kubernetes.io/fakeAttacher"}}}}) {
|
||||
@ -154,7 +154,7 @@ func TestGetAccessModes(t *testing.T) {
|
||||
installPluginUnderTest(t, "kubernetes.io", "fakeAttacher", tmpDir, execScriptTempl1, nil)
|
||||
plugMgr.InitPlugins(nil, GetDynamicPluginProber(tmpDir, runner), volumetest.NewFakeVolumeHost(t, tmpDir, nil, nil))
|
||||
|
||||
plugin, err := plugMgr.FindPersistentPluginByName("flexvolume-kubernetes.io/fakeAttacher")
|
||||
plugin, err := plugMgr.FindPersistentPluginByName("kubernetes.io/fakeAttacher")
|
||||
if err != nil {
|
||||
t.Fatalf("Can't find the plugin by name")
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
flexVolumePluginName = "kubernetes.io/flexvolume"
|
||||
flexVolumePluginNamePrefix = "flexvolume-"
|
||||
flexVolumePluginName = "kubernetes.io/flexvolume"
|
||||
)
|
||||
|
||||
// FlexVolumePlugin object.
|
||||
@ -114,7 +113,7 @@ func (plugin *flexVolumePlugin) getExecutable() string {
|
||||
|
||||
// Name is part of the volume.VolumePlugin interface.
|
||||
func (plugin *flexVolumePlugin) GetPluginName() string {
|
||||
return flexVolumePluginNamePrefix + plugin.driverName
|
||||
return plugin.driverName
|
||||
}
|
||||
|
||||
// GetVolumeName is part of the volume.VolumePlugin interface.
|
||||
|
@ -140,7 +140,7 @@ func (prober *flexVolumeProber) newProbeEvent(driverDirName string, op volume.Pr
|
||||
probeEvent.PluginName = plugin.GetPluginName()
|
||||
} else if op == volume.ProbeRemove {
|
||||
driverName := utilstrings.UnescapeQualifiedName(driverDirName)
|
||||
probeEvent.PluginName = flexVolumePluginNamePrefix + driverName
|
||||
probeEvent.PluginName = driverName
|
||||
|
||||
} else {
|
||||
return probeEvent, fmt.Errorf("Unknown Operation on directory: %s. ", driverDirName)
|
||||
|
@ -704,7 +704,7 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
|
||||
}
|
||||
|
||||
if len(matches) == 0 {
|
||||
return nil, fmt.Errorf("no volume plugin matched")
|
||||
return nil, fmt.Errorf("no volume plugin matched name: %s", name)
|
||||
}
|
||||
if len(matches) > 1 {
|
||||
matchedPluginNames := []string{}
|
||||
|
@ -128,7 +128,7 @@ var _ = utils.SIGDescribe("Detaching volumes", func() {
|
||||
})
|
||||
|
||||
func getUniqueVolumeName(pod *v1.Pod, driverName string) string {
|
||||
return fmt.Sprintf("flexvolume-k8s/%s/%s", driverName, pod.Spec.Volumes[0].Name)
|
||||
return fmt.Sprintf("k8s/%s/%s", driverName, pod.Spec.Volumes[0].Name)
|
||||
}
|
||||
|
||||
func waitForVolumesNotInUse(client clientset.Interface, nodeName, volumeName string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user