From a95a1ff6f160b7d586d606b8f80c9cfe3b92fea2 Mon Sep 17 00:00:00 2001 From: mtanino Date: Mon, 18 Sep 2017 22:28:37 -0400 Subject: [PATCH] FC plugin: Return target wwn + lun at GetVolumeName() At volume attach/detach controller, GetVolumeName() is expected to return unique volume identifier, but FC plugin didn't return unique identifier if user specified FC volume using target wwn and lun. In order to return unique identifier, GetVolumeName() should use combination of target wwn and lun. Fixes #52690 --- pkg/volume/fc/fc.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/volume/fc/fc.go b/pkg/volume/fc/fc.go index 096a24df387..2b4e387c25b 100644 --- a/pkg/volume/fc/fc.go +++ b/pkg/volume/fc/fc.go @@ -61,9 +61,12 @@ func (plugin *fcPlugin) GetVolumeName(spec *volume.Spec) (string, error) { return "", err } - if len(volumeSource.TargetWWNs) != 0 { + // API server validates these parameters beforehand but attach/detach + // controller creates volumespec without validation. They may be nil + // or zero length. We should check again to avoid unexpected conditions. + if len(volumeSource.TargetWWNs) != 0 && volumeSource.Lun != nil { // TargetWWNs are the FibreChannel target worldwide names - return fmt.Sprintf("%v", volumeSource.TargetWWNs), nil + return fmt.Sprintf("%v:%v", volumeSource.TargetWWNs, *volumeSource.Lun), nil } else if len(volumeSource.WWIDs) != 0 { // WWIDs are the FibreChannel World Wide Identifiers return fmt.Sprintf("%v", volumeSource.WWIDs), nil