Commit d503b807 authored by Ed Bartosh's avatar Ed Bartosh

Fix adding FileContentCheck

Current code adds FileContentCheck only for the first API Server mentioned in the command line. The test is never added as net.ParseIP always fails because <address>:<port> is passed to it instead of <address>. Fixed both issues by introducing a loop over all API Servers and splitting <address>:<port> before passing <address> to the net.ParseIP API.
parent 068e1642
......@@ -986,12 +986,16 @@ func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.NodeConfigura
criCtlChecker)
}
if len(cfg.DiscoveryTokenAPIServers) > 0 {
if ip := net.ParseIP(cfg.DiscoveryTokenAPIServers[0]); ip != nil {
if ip.To4() == nil && ip.To16() != nil {
checks = append(checks,
FileContentCheck{Path: bridgenf6, Content: []byte{'1'}},
)
for _, server := range cfg.DiscoveryTokenAPIServers {
ipstr, _, err := net.SplitHostPort(server)
if err == nil {
if ip := net.ParseIP(ipstr); ip != nil {
if ip.To4() == nil && ip.To16() != nil {
checks = append(checks,
FileContentCheck{Path: bridgenf6, Content: []byte{'1'}},
)
break // Ensure that check is added only once
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment