From d503b807d5f7037a1f5bb8621887d6c792113cd9 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Thu, 25 Jan 2018 12:45:37 +0200 Subject: [PATCH] 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
: is passed to it instead of
. Fixed both issues by introducing a loop over all API Servers and splitting
: before passing
to the net.ParseIP API. --- cmd/kubeadm/app/preflight/checks.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/kubeadm/app/preflight/checks.go b/cmd/kubeadm/app/preflight/checks.go index 42f71eebf31..dd81c972328 100644 --- a/cmd/kubeadm/app/preflight/checks.go +++ b/cmd/kubeadm/app/preflight/checks.go @@ -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 + } } } }