Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#15 from 27149chen/fix/use_os_is_not…
Browse files Browse the repository at this point in the history
…_exist

use os.IsNotExist and other small fixes
  • Loading branch information
k8s-ci-robot authored Jan 6, 2020
2 parents 1efb74c + 7458a41 commit 4a4d032
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,12 @@ func sessionExists(tgtPortal, tgtIQN string) (bool, error) {
if err != nil {
return false, err
}
var existingSessions []iscsiSession
for _, s := range sessions {
if tgtIQN == s.IQN && tgtPortal == s.Portal {
existingSessions = append(existingSessions, s)
return true, nil
}
}
exists := false
if len(existingSessions) > 0 {
exists = true
}
return exists, nil
return false, nil
}

func extractTransportName(output string) string {
Expand All @@ -136,8 +131,8 @@ func getCurrentSessions() ([]iscsiSession, error) {
}
return nil, err
}
session := parseSessions(out)
return session, err
sessions := parseSessions(out)
return sessions, err
}

func waitForPathToExist(devicePath *string, maxRetries, intervalSeconds int, deviceTransport string) (bool, error) {
Expand All @@ -154,7 +149,7 @@ func waitForPathToExistImpl(devicePath *string, maxRetries, intervalSeconds int,
err = nil
if deviceTransport == "tcp" {
_, err = osStat(*devicePath)
if err != nil && !strings.Contains(err.Error(), "no such file or directory") {
if err != nil && !os.IsNotExist(err) {
debug.Printf("Error attempting to stat device: %s", err.Error())
return false, err
} else if err != nil {
Expand Down

0 comments on commit 4a4d032

Please sign in to comment.