Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pkg/ibm/ibmz_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func checkIfIpIsLive(ctx context.Context, ip string) error {
server, err := net.ResolveTCPAddr("tcp", ip+":22")
if err != nil {
log.Error(err, "failed to resolve ip address")
return err
}
conn, err := net.DialTimeout(server.Network(), server.String(), 5*time.Second)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions pkg/ibm/ibmz_helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibm

import (
"context"
"fmt"
"regexp"

Expand Down Expand Up @@ -101,4 +102,17 @@ var _ = Describe("IBM s390x Helper Functions", func() {
"System Z Max Tag Length"),
)
})

Describe("The checkIfIpIsLive function", func() {
When("the DNS resolution of the host fails", func() {
It("should return an error instead of panicking", func() {
ctx := context.Background()
// "a b c" contains spaces, which are invalid in DNS names
// — this causes net.ResolveTCPAddr to fail immediately
// (0ms, pure local resolution) without any network call.
err := checkIfIpIsLive(ctx, "a b c")
Expect(err).Should(HaveOccurred())
})
})
})
})
Loading