Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have nodeup retry kops-controller bootstrapping sooner if DNS isn't setup #11101

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.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
Expand Down