Skip to content

Commit 9a5b25b

Browse files
authored
CON-3078 Added changes to pass access protocol type to create host request (#447)
* Added changes to pass access protocol type to create hostrequest * Addressed review comments specific to protocol type --------- Signed-off-by: jyotsna-lothe <jyotsna.lothe@hpe.com>
1 parent 5297d90 commit 9a5b25b

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/Scalingo/go-etcd-lock v3.0.1+incompatible
99
github.com/container-storage-interface/spec v1.7.0
1010
github.com/golang/protobuf v1.5.4
11-
github.com/hpe-storage/common-host-libs v0.0.0-20250314182729-baa69ca334d9
11+
github.com/hpe-storage/common-host-libs v0.0.0-20250403163049-437bf8e4afe4
1212
github.com/hpe-storage/k8s-custom-resources v0.0.0-20240118202512-5f62990a7c2d
1313
github.com/kubernetes-csi/csi-lib-utils v0.11.0
1414
github.com/kubernetes-csi/csi-test v2.2.0+incompatible

go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb
268268
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
269269
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
270270
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
271-
github.com/hpe-storage/common-host-libs v0.0.0-20250314182729-baa69ca334d9 h1:26+R8LY2r4M5UQwwf2IEDtD7v+U6TpnijsJDMHY8mEA=
272-
github.com/hpe-storage/common-host-libs v0.0.0-20250314182729-baa69ca334d9/go.mod h1:dLKaIzPACd56mr+xk5uInMUzbyFym1KUV1ArXSNYjuI=
271+
272+
github.com/hpe-storage/common-host-libs v0.0.0-20240717051902-d204e2e2e8fd h1:nUxP2DVIdJJHJJv2r7NBET9asoxhxOtmxSoFTfJHY+s=
273+
github.com/hpe-storage/common-host-libs v0.0.0-20240717051902-d204e2e2e8fd/go.mod h1:ihkZYcRtUpjrwM2Rh/eU1iIDijUD8YJe7bSS92sXtJk=
274+
github.com/hpe-storage/common-host-libs v0.0.0-20250403163049-437bf8e4afe4 h1:AIpz6rbW3TYlR45vRApYo4FkA4mzfBLZl3s03W1FF1w=
275+
github.com/hpe-storage/common-host-libs v0.0.0-20250403163049-437bf8e4afe4/go.mod h1:dLKaIzPACd56mr+xk5uInMUzbyFym1KUV1ArXSNYjuI=
273276
github.com/hpe-storage/k8s-custom-resources v0.0.0-20240118202512-5f62990a7c2d h1:ui+o/+dBn3pwOBHL3AB14XsYaeogpPJZF0Dk3vJh7zY=
274277
github.com/hpe-storage/k8s-custom-resources v0.0.0-20240118202512-5f62990a7c2d/go.mod h1:+zrGrGKf/jqr38KxLEGRll+UsjeUybdLH0MZCBxPPoI=
275278
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=

pkg/driver/controller_server.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

vendor/github.com/hpe-storage/common-host-libs/model/types.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)