Add spec.Name() to the configmap GetVolumeName()
This is to base the name on the volume not just on the source configMap. If you have 2 volumes that both have the same configMap as a source, the volume is see as being in the attached state (it's state is looked up based on GetVolumeName()). See bug #28502
This commit is contained in:
parent
1ff33c576d
commit
d7150bfaea
@ -60,7 +60,10 @@ func (plugin *configMapPlugin) GetVolumeName(spec *volume.Spec) (string, error)
|
|||||||
return "", fmt.Errorf("Spec does not reference a ConfigMap volume type")
|
return "", fmt.Errorf("Spec does not reference a ConfigMap volume type")
|
||||||
}
|
}
|
||||||
|
|
||||||
return volumeSource.Name, nil
|
return fmt.Sprintf(
|
||||||
|
"%v/%v",
|
||||||
|
spec.Name(),
|
||||||
|
volumeSource.Name), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *configMapPlugin) CanSupport(spec *volume.Spec) bool {
|
func (plugin *configMapPlugin) CanSupport(spec *volume.Spec) bool {
|
||||||
|
@ -237,6 +237,14 @@ func TestPlugin(t *testing.T) {
|
|||||||
t.Errorf("Got a nil Mounter")
|
t.Errorf("Got a nil Mounter")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vName, err := plugin.GetVolumeName(volume.NewSpecFromVolume(volumeSpec))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Failed to GetVolumeName: %v", err)
|
||||||
|
}
|
||||||
|
if vName != "test_volume_name/test_configmap_name" {
|
||||||
|
t.Errorf("Got unexpect VolumeName %v", vName)
|
||||||
|
}
|
||||||
|
|
||||||
volumePath := mounter.GetPath()
|
volumePath := mounter.GetPath()
|
||||||
if !strings.HasSuffix(volumePath, fmt.Sprintf("pods/test_pod_uid/volumes/kubernetes.io~configmap/test_volume_name")) {
|
if !strings.HasSuffix(volumePath, fmt.Sprintf("pods/test_pod_uid/volumes/kubernetes.io~configmap/test_volume_name")) {
|
||||||
t.Errorf("Got unexpected path: %s", volumePath)
|
t.Errorf("Got unexpected path: %s", volumePath)
|
||||||
|
Loading…
Reference in New Issue
Block a user