Skip to content

Commit

Permalink
Have nodeup retry kops-controller bootstrapping sooner if DNS isn't s…
Browse files Browse the repository at this point in the history
…etup
  • Loading branch information
rifelpet committed Mar 21, 2021
1 parent 86492a8 commit 6151995
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions upup/pkg/fi/nodeup/nodetasks/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions upup/pkg/fi/nodeup/nodetasks/bootstrap_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -155,6 +159,19 @@ func (b *KopsBootstrapClient) QueryBootstrap(ctx context.Context, req *nodeup.Bo
}
}

if ips, err := net.LookupIP(b.BaseURL.Host); err != nil {
if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound {
return nil, fi.NewTryAgainLaterError("kops-controller DNS not setup yet")
}
return nil, err
} else {
for _, ip := range ips {
if ip.String() == cloudup.PlaceholderIP {
return nil, fi.NewTryAgainLaterError("kops-controller DNS not setup yet")
}
}
}

reqBytes, err := json.Marshal(req)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6151995

Please sign in to comment.