Commit d7150bfa authored by Angus Salkeld's avatar Angus Salkeld

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
parent 1ff33c57
...@@ -60,7 +60,10 @@ func (plugin *configMapPlugin) GetVolumeName(spec *volume.Spec) (string, error) ...@@ -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) { ...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment