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:
Angus Salkeld 2016-07-06 16:39:43 +02:00
parent 1ff33c576d
commit d7150bfaea
2 changed files with 12 additions and 1 deletions

View File

@ -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 volumeSource.Name, nil
return fmt.Sprintf(
"%v/%v",
spec.Name(),
volumeSource.Name), nil
}
func (plugin *configMapPlugin) CanSupport(spec *volume.Spec) bool {

View File

@ -237,6 +237,14 @@ func TestPlugin(t *testing.T) {
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()
if !strings.HasSuffix(volumePath, fmt.Sprintf("pods/test_pod_uid/volumes/kubernetes.io~configmap/test_volume_name")) {
t.Errorf("Got unexpected path: %s", volumePath)