diff --git a/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel b/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel index c386d4b427285..f21435d26870b 100644 --- a/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel +++ b/upup/pkg/fi/nodeup/nodetasks/BUILD.bazel @@ -27,6 +27,7 @@ go_library( "//pkg/kubeconfig:go_default_library", "//pkg/pki:go_default_library", "//upup/pkg/fi:go_default_library", + "//upup/pkg/fi/cloudup:go_default_library", "//upup/pkg/fi/nodeup/cloudinit:go_default_library", "//upup/pkg/fi/nodeup/local:go_default_library", "//upup/pkg/fi/utils:go_default_library", diff --git a/upup/pkg/fi/nodeup/nodetasks/bootstrap_client.go b/upup/pkg/fi/nodeup/nodetasks/bootstrap_client.go index 1ae1e7eca02e6..34e39c7f1abf5 100644 --- a/upup/pkg/fi/nodeup/nodetasks/bootstrap_client.go +++ b/upup/pkg/fi/nodeup/nodetasks/bootstrap_client.go @@ -27,13 +27,16 @@ import ( "encoding/pem" "fmt" "io/ioutil" + "net" "net/http" "net/url" "path" + "time" "k8s.io/kops/pkg/apis/nodeup" "k8s.io/kops/pkg/pki" "k8s.io/kops/upup/pkg/fi" + "k8s.io/kops/upup/pkg/fi/cloudup" ) type BootstrapClientTask struct { @@ -146,6 +149,7 @@ func (b *KopsBootstrapClient) QueryBootstrap(ctx context.Context, req *nodeup.Bo certPool.AppendCertsFromPEM(b.CA) b.httpClient = &http.Client{ + Timeout: time.Duration(15) * time.Second, Transport: &http.Transport{ TLSClientConfig: &tls.Config{ RootCAs: certPool, @@ -155,6 +159,19 @@ func (b *KopsBootstrapClient) QueryBootstrap(ctx context.Context, req *nodeup.Bo } } + if ips, err := net.LookupIP(b.BaseURL.Hostname()); err != nil { + if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound { + return nil, fi.NewTryAgainLaterError(fmt.Sprintf("kops-controller DNS not setup yet (not found: %v)", dnsErr)) + } + return nil, err + } else { + for _, ip := range ips { + if ip.String() == cloudup.PlaceholderIP { + return nil, fi.NewTryAgainLaterError(fmt.Sprintf("kops-controller DNS not setup yet (placeholder IP found: %v)", ips)) + } + } + } + reqBytes, err := json.Marshal(req) if err != nil { return nil, err