Skip to content

Commit 2076e98

Browse files
nkvetsinskiNikolay Kvetsinski
andauthored
fix(nodeadm): add retry to net.LookupHost (#2585)
* fix(nodeadm): Add retry to net.LookupHost() --------- Co-authored-by: Nikolay Kvetsinski <kvetsins@amazon.com>
1 parent d4df9a2 commit 2076e98

File tree

14 files changed

+1712
-2
lines changed

14 files changed

+1712
-2
lines changed

nodeadm/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ require (
2727
cel.dev/expr v0.24.0 // indirect
2828
github.com/Masterminds/semver/v3 v3.4.0 // indirect
2929
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
30+
github.com/avast/retry-go/v5 v5.0.0 // indirect
3031
github.com/aws/aws-sdk-go-v2/credentials v1.19.7 // indirect
3132
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.17 // indirect
3233
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.17 // indirect

nodeadm/go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1
66
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
77
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
88
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
9+
github.com/avast/retry-go v2.7.0+incompatible h1:XaGnzl7gESAideSjr+I8Hki/JBi+Yb9baHlMRPeSC84=
10+
github.com/avast/retry-go v2.7.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
11+
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
12+
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
13+
github.com/avast/retry-go/v5 v5.0.0 h1:kf1Qc2UsTZ4qq8elDymqfbISvkyMuhgRxuJqX2NHP7k=
14+
github.com/avast/retry-go/v5 v5.0.0/go.mod h1://d+usmKWio1agtZfS1H/ltTqwtIfBnRq9zEwjc3eH8=
915
github.com/aws/aws-sdk-go-v2 v1.41.1 h1:ABlyEARCDLN034NhxlRUSZr4l71mh+T5KAeGh6cerhU=
1016
github.com/aws/aws-sdk-go-v2 v1.41.1/go.mod h1:MayyLB8y+buD9hZqkCW3kX1AKq07Y5pXxtgB+rRFhz0=
1117
github.com/aws/aws-sdk-go-v2/config v1.32.7 h1:vxUyWGUwmkQ2g19n7JY/9YL8MfAIl7bTesIUykECXmY=

nodeadm/internal/kubelet/config.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020
k8skubelet "k8s.io/kubelet/config/v1beta1"
2121

22+
"github.com/avast/retry-go/v5"
2223
"github.com/aws/smithy-go/ptr"
23-
2424
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/api"
2525
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/aws/imds"
2626
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/containerd"
@@ -178,7 +178,20 @@ func (ksc *kubeletConfig) withOutpostSetup(cfg *api.NodeConfig) error {
178178
}
179179

180180
// TODO: cleanup
181-
ipAddresses, err := net.LookupHost(apiUrl.Host)
181+
var ipAddresses []string
182+
err = retry.New(
183+
retry.Attempts(6),
184+
retry.Delay(200*time.Millisecond),
185+
retry.OnRetry(func(n uint, err error) {
186+
zap.L().Info("Retrying DNS lookup after error", zap.Error(err))
187+
}),
188+
).Do(
189+
func() error {
190+
var err error
191+
ipAddresses, err = net.LookupHost(apiUrl.Host)
192+
return err
193+
},
194+
)
182195
if err != nil {
183196
return err
184197
}

nodeadm/vendor/github.com/avast/retry-go/v5/.gitignore

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodeadm/vendor/github.com/avast/retry-go/v5/.godocdown.tmpl

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodeadm/vendor/github.com/avast/retry-go/v5/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodeadm/vendor/github.com/avast/retry-go/v5/Makefile

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)