Merge pull request #82267 from kad/issue-1769

kubeadm: Form correct URL for IPv6 in HTTPProxy check
This commit is contained in:
Kubernetes Prow Robot 2019-09-03 07:56:31 -07:00 committed by GitHub
commit 975d0736b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -431,9 +431,12 @@ func (hst HTTPProxyCheck) Name() string {
// Check validates http connectivity type, direct or via proxy.
func (hst HTTPProxyCheck) Check() (warnings, errorList []error) {
klog.V(1).Infoln("validating if the connectivity type is via proxy or direct")
u := (&url.URL{Scheme: hst.Proto, Host: hst.Host}).String()
u := &url.URL{Scheme: hst.Proto, Host: hst.Host}
if utilsnet.IsIPv6String(hst.Host) {
u.Host = net.JoinHostPort(hst.Host, "1234")
}
req, err := http.NewRequest("GET", u, nil)
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
return nil, []error{err}
}

View File

@ -590,6 +590,22 @@ func TestHTTPProxyCheck(t *testing.T) {
}, // Expected to go via proxy, range is not in 2001:db8::/48
expectWarnings: true,
},
{
name: "IPv6 direct access, no brackets",
check: HTTPProxyCheck{
Proto: "https",
Host: "2001:db8::1:15",
}, // Expected to be accessed directly, part of 2001:db8::/48 in NO_PROXY
expectWarnings: false,
},
{
name: "IPv6 via proxy, no brackets",
check: HTTPProxyCheck{
Proto: "https",
Host: "2001:db8:1::1:15",
}, // Expected to go via proxy, range is not in 2001:db8::/48
expectWarnings: true,
},
}
// Save current content of *_proxy and *_PROXY variables.