mirror of https://github.com/kubernetes/kops.git
Have nodeup retry kops-controller bootstrapping sooner if DNS isn't setup
This commit is contained in:
parent
86492a81a5
commit
763d1e2bd0
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue