@@ -858,32 +858,36 @@ func (driver *Driver) controllerPublishVolume(
858858 existingNode , err := storageProvider .GetNodeContext (node .UUID )
859859 if err != nil {
860860 log .Errorf ("Error retrieving the node info from the CSP. err: %s" , err .Error ())
861- return nil , status .Error (codes .Unavailable ,
862- fmt .Sprintf ("Error retrieving the node info for ID %s from the CSP, err: %s" , node .UUID , err .Error ()))
861+ return nil , status .Error (codes .Unavailable ,
862+ fmt .Sprintf ("Error retrieving the node info for ID %s from the CSP, err: %s" , node .UUID , err .Error ()))
863863 }
864+
865+ // Configure access protocol defaulting to iSCSI when unspecified
866+ var requestedAccessProtocol = volumeContext [accessProtocolKey ]
867+ if requestedAccessProtocol == "" {
868+ // by default when no protocol specified make iscsi as default
869+ requestedAccessProtocol = iscsi
870+ log .Tracef ("Defaulting to access protocol %s" , requestedAccessProtocol )
871+ } else if requestedAccessProtocol == "iscsi" {
872+ requestedAccessProtocol = iscsi
873+ } else if requestedAccessProtocol == "fc" {
874+ requestedAccessProtocol = fc
875+ }
876+
864877 if existingNode != nil {
865878 log .Tracef ("CSP has already been notified about the node with ID %s and UUID %s" , existingNode .ID , existingNode .UUID )
866879 } else {
867880 // If node does not already exists, then set context here
868881 log .Tracef ("Notifying CSP about Node with ID %s and UUID %s" , node .ID , node .UUID )
882+ log .Tracef ("AccessProtocol set is %s" , requestedAccessProtocol )
883+ node .AccessProtocol = requestedAccessProtocol
869884 if err = storageProvider .SetNodeContext (node ); err != nil {
870885 log .Error ("err: " , err .Error ())
871886 return nil , status .Error (codes .Unavailable ,
872887 fmt .Sprintf ("Failed to provide node %s to CSP err: %s" , node .ID , err .Error ()))
873888 }
874889 }
875890
876- // Configure access protocol defaulting to iSCSI when unspecified
877- var requestedAccessProtocol = volumeContext [accessProtocolKey ]
878- if requestedAccessProtocol == "" {
879- if len (node .Iqns ) != 0 {
880- requestedAccessProtocol = iscsi
881- } else {
882- requestedAccessProtocol = fc
883- }
884- log .Tracef ("Defaulting to access protocol %s" , requestedAccessProtocol )
885- }
886-
887891 // Add ACL to the volume based on the requested Node
888892 publishInfo , err := storageProvider .PublishVolume (volume .ID , node .UUID , requestedAccessProtocol )
889893 if err != nil {
0 commit comments