Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: correct ControllerPublishVolume csi-sanity issues #13

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (client *Client) mapVolumeProcess(volumeName, initiatorName string, lun int
if metadata.ReturnCode == initiatorNicknameOrIdentifierNotFound {
nodeIDParts := strings.Split(initiatorName, ":")
if len(nodeIDParts) < 2 {
return status.Error(codes.InvalidArgument, "specified node ID is not a valid IQN")
return status.Error(codes.NotFound, "specified node ID is not a valid IQN")
}

nickname := strings.Join(nodeIDParts[1:], ":")
Expand Down Expand Up @@ -416,9 +416,13 @@ func (client *Client) CheckVolumeExists(volumeID string, size int64) (bool, erro
// PublishVolume: Attach a volume to an initiator
func (client *Client) PublishVolume(volumeId string, initiatorName string) (string, error) {

hostNames, _, err := client.GetVolumeMapsHostNames(volumeId)
hostNames, apistatus, err := client.GetVolumeMapsHostNames(volumeId)
if err != nil {
return "", err
if apistatus != nil && apistatus.ReturnCode == volumeNotFoundErrorCode {
return "", status.Errorf(codes.NotFound, "The specified volume (%s) was not found.", volumeId)
} else {
return "", err
}
}
for _, hostName := range hostNames {
if hostName != initiatorName {
Expand All @@ -430,6 +434,7 @@ func (client *Client) PublishVolume(volumeId string, initiatorName string) (stri
if err != nil {
return "", err
}

klog.Infof("using LUN %d", lun)

if err = client.mapVolumeProcess(volumeId, initiatorName, lun); err != nil {
Expand Down