Skip to content

Commit c5aa96c

Browse files
feat: allow ipv6 services (#218)
* feat: allow ipv6 services * test(servicecheck): add ipv6.google.com check --------- Co-authored-by: Clément Nussbaumer <clement@n8r.ch>
1 parent 56cde01 commit c5aa96c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

internal/servicecheck/servicecheck.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (c *Checker) APIServerDirect(ctx context.Context) string {
143143
return skippedStr
144144
}
145145

146-
apiurl := fmt.Sprintf("https://%s:%s/version", c.KubernetesServiceHost, c.KubernetesServicePort)
146+
apiurl := fmt.Sprintf("https://%s/version", net.JoinHostPort(c.KubernetesServiceHost, c.KubernetesServicePort))
147147

148148
return c.doRequest(ctx, apiurl, false)
149149
}
@@ -154,7 +154,7 @@ func (c *Checker) APIServerDNS(ctx context.Context) string {
154154
return skippedStr
155155
}
156156

157-
apiurl := fmt.Sprintf("https://%s:%s/version", c.KubernetesServiceDNS, c.KubernetesServicePort)
157+
apiurl := fmt.Sprintf("https://%s/version", net.JoinHostPort(c.KubernetesServiceDNS, c.KubernetesServicePort))
158158

159159
return c.doRequest(ctx, apiurl, false)
160160
}
@@ -190,8 +190,8 @@ func (c *Checker) measure(ctx context.Context, wg *sync.WaitGroup, res *sync.Map
190190

191191
func podIPtoURL(podIP string, useTLS bool) string {
192192
if useTLS {
193-
return "https://" + podIP + ":8443/alwayshappy"
193+
return "https://" + net.JoinHostPort(podIP, "8443") + "/alwayshappy"
194194
}
195195

196-
return "http://" + podIP + ":8080/alwayshappy"
196+
return "http://" + net.JoinHostPort(podIP, "8080") + "/alwayshappy"
197197
}

internal/servicecheck/servicecheck_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func TestCombined(t *testing.T) {
5757
checker.ExtraChecks = map[string]string{
5858
"check_not_found": server.URL + "/not-found",
5959
"check_ok": server.URL + "/ok",
60+
"check_ipv6": "https://ipv6.google.com/",
6061
}
6162
r.NoError(err)
6263
r.NotNil(checker)
@@ -67,6 +68,7 @@ func TestCombined(t *testing.T) {
6768

6869
r.Equal(okStr, checker.LastCheckResult[NeighbourhoodState])
6970
r.Equal(okStr, checker.LastCheckResult["check_ok"])
71+
// r.Equal(okStr, checker.LastCheckResult["check_ipv6"]) // gh-action doesn't support IPv6 yet
7072
r.Equal("404 Not Found", checker.LastCheckResult["check_not_found"])
7173
})
7274
}

0 commit comments

Comments
 (0)