Skip to content

Commit

Permalink
Upgrade deps (#452)
Browse files Browse the repository at this point in the history
* upgrade deps

* upgrade deps and fix compatibility issues

* add context to drain helper

* remove flag resets in tests

* add more license checks

* send license report to file first

* add bsd-2-clause to allowed licenses

* update third party licenses

* remove nolinterr annotations
  • Loading branch information
bwagner5 authored Jun 14, 2021
1 parent 31a5a99 commit 62e925b
Show file tree
Hide file tree
Showing 25 changed files with 4,650 additions and 902 deletions.
4,010 changes: 3,592 additions & 418 deletions THIRD_PARTY_LICENSES

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions cmd/node-termination-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ func main() {
stopCh <- struct{}{}
}()
//will retry 4 times with an interval of 2 seconds.
//nolint:errcheck
wait.PollImmediateUntil(2*time.Second, func() (done bool, err error) {
err = wait.PollImmediateUntil(2*time.Second, func() (done bool, err error) {
err = handleRebootUncordon(nthConfig.NodeName, interruptionEventStore, *node)
if err != nil {
log.Err(err).Msgf("Unable to complete the uncordon after reboot workflow on startup, retrying")
log.Warn().Err(err).Msgf("Unable to complete the uncordon after reboot workflow on startup, retrying")
}
return false, nil
}, stopCh)
if err != nil {
log.Warn().Err(err).Msgf("All retries failed, unable to complete the uncordon after reboot workflow")
}
}

interruptionChan := make(chan monitor.InterruptionEvent)
Expand Down
25 changes: 14 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ go 1.16

require (
github.com/Masterminds/sprig/v3 v3.2.2
github.com/aws/aws-sdk-go v1.33.1
github.com/aws/aws-sdk-go v1.38.55
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/rs/zerolog v1.18.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.6.1
go.opentelemetry.io/otel v0.6.0
go.opentelemetry.io/otel/exporters/metric/prometheus v0.6.0
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
k8s.io/api v0.0.0-20191010143144-fbf594f18f80
k8s.io/apimachinery v0.0.0-20191016060620-86f2f1b9c076
k8s.io/client-go v0.0.0-20191014070654-bd505ee787b2
k8s.io/kubectl v0.0.0-20191016234702-5d0b8f240400
github.com/rs/zerolog v1.22.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.20.0
go.opentelemetry.io/otel v0.20.0
go.opentelemetry.io/otel/exporters/metric/prometheus v0.20.0
go.opentelemetry.io/otel/metric v0.20.0
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210608053332-aa57babbf139
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
k8s.io/kubectl v0.21.1
)
861 changes: 712 additions & 149 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/config/config_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func TestIsConfigProvided(t *testing.T) {
result := isConfigProvided(cliArgName, envVarName)
h.Equals(t, false, result)

//nolint:errcheck
flag.Set(cliArgName, value)
err := flag.Set(cliArgName, value)
h.Ok(t, err)
result = isConfigProvided(cliArgName, envVarName)
h.Equals(t, true, result)

Expand Down
8 changes: 4 additions & 4 deletions pkg/ec2metadata/ec2metadata_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestGetV2Token(t *testing.T) {
h.Equals(t, req.Header.Get(tokenTTLHeader), strconv.Itoa(tokenTTL))
h.Equals(t, req.URL.String(), tokenRefreshPath)
rw.Header().Set(tokenTTLHeader, "100")
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
}))
defer server.Close()
imds := New(server.URL, 1)
Expand All @@ -76,8 +76,8 @@ func TestGetV2TokenBadTTLHeader(t *testing.T) {
h.Equals(t, req.Header.Get(tokenTTLHeader), strconv.Itoa(tokenTTL))
h.Equals(t, req.URL.String(), tokenRefreshPath)
rw.Header().Set(tokenTTLHeader, "badttl")
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
}))
defer server.Close()
imds := New(server.URL, 1)
Expand Down
104 changes: 52 additions & 52 deletions pkg/ec2metadata/ec2metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestRequestV1(t *testing.T) {
return
}
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(`OK`))
_, err := rw.Write([]byte(`OK`))
h.Ok(t, err)
}))
defer server.Close()

Expand All @@ -61,14 +61,14 @@ func TestRequestV2(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(`OK`))
_, err := rw.Write([]byte(`OK`))
h.Ok(t, err)
}))
defer server.Close()

Expand Down Expand Up @@ -125,8 +125,8 @@ func TestRequest401(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.URL.String(), requestPath)
Expand Down Expand Up @@ -167,17 +167,17 @@ func TestGetSpotITNEventSuccess(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(fmt.Sprintf(`{
_, err := rw.Write([]byte(fmt.Sprintf(`{
"action": "%s",
"time": "%s"
}`, instanceAction, time)))
h.Ok(t, err)
}))
defer server.Close()

Expand All @@ -201,8 +201,8 @@ func TestGetSpotITNEvent404Success(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
Expand All @@ -226,14 +226,14 @@ func TestGetSpotITNEventBadJSON(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(`{"action": false}`))
_, err := rw.Write([]byte(`{"action": false}`))
h.Ok(t, err)
}))
defer server.Close()

Expand All @@ -251,8 +251,8 @@ func TestGetSpotITNEvent500Failure(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
Expand Down Expand Up @@ -291,14 +291,13 @@ func TestGetScheduledMaintenanceEventsSuccess(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(fmt.Sprintf(`[
_, err := rw.Write([]byte(fmt.Sprintf(`[
{
"NotBefore" : "%s",
"Code" : "%s",
Expand All @@ -308,6 +307,7 @@ func TestGetScheduledMaintenanceEventsSuccess(t *testing.T) {
"State" : "%s"
}
]`, notBefore, code, description, eventId, notAfter, state)))
h.Ok(t, err)
}))
defer server.Close()

Expand Down Expand Up @@ -337,8 +337,8 @@ func TestGetScheduledMaintenanceEvents500Failure(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
Expand All @@ -361,14 +361,14 @@ func TestGetScheduledMaintenanceEventsBadJSON(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(`{"notBefore": false}`))
_, err := rw.Write([]byte(`{"notBefore": false}`))
h.Ok(t, err)
}))
defer server.Close()

Expand Down Expand Up @@ -397,16 +397,16 @@ func TestGetRebalanceRecommendationEventSuccess(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(fmt.Sprintf(`{
_, err := rw.Write([]byte(fmt.Sprintf(`{
"noticeTime": "%s"
}`, noticeTime)))
h.Ok(t, err)
}))
defer server.Close()

Expand All @@ -429,8 +429,8 @@ func TestGetRebalanceRecommendationEvent404Success(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
Expand All @@ -454,14 +454,14 @@ func TestGetRebalanceRecommendationEventBadJSON(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(`{"action": false, "noticeTime": 2020-10-26T15:55:55Z}`))
_, err := rw.Write([]byte(`{"action": false, "noticeTime": 2020-10-26T15:55:55Z}`))
h.Ok(t, err)
}))
defer server.Close()

Expand All @@ -479,8 +479,8 @@ func TestGetRebalanceRecommendationEvent500Failure(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
Expand Down Expand Up @@ -511,8 +511,8 @@ func TestGetMetadataServiceRequest404(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
Expand Down Expand Up @@ -544,14 +544,14 @@ func TestGetMetadataServiceSuccess(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
h.Equals(t, req.Header.Get("X-aws-ec2-metadata-token"), "token")
h.Equals(t, req.URL.String(), requestPath)
//nolint:errcheck
rw.Write([]byte(`x1.32xlarge`))
_, err := rw.Write([]byte(`x1.32xlarge`))
h.Ok(t, err)
}))
defer server.Close()

Expand All @@ -569,12 +569,12 @@ func TestGetNodeMetadata(t *testing.T) {
rw.Header().Add("X-aws-ec2-metadata-token-ttl-seconds", "100")
if req.URL.String() == "/latest/api/token" {
rw.WriteHeader(200)
//nolint:errcheck
rw.Write([]byte(`token`))
_, err := rw.Write([]byte(`token`))
h.Ok(t, err)
return
}
//nolint:errcheck
rw.Write([]byte(`metadata`))
_, err := rw.Write([]byte(`metadata`))
h.Ok(t, err)
}))
defer server.Close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ func (m RebalanceRecommendationMonitor) checkForRebalanceRecommendation() (*moni

// There's no EventID returned so we'll create it using a hash to prevent duplicates.
hash := sha256.New()
//nolint:errcheck
hash.Write([]byte(fmt.Sprintf("%v", rebalanceRecommendation)))
_, err = hash.Write([]byte(fmt.Sprintf("%v", rebalanceRecommendation)))
if err != nil {
return nil, fmt.Errorf("There was a problem creating an event ID from the event: %w", err)
}

return &monitor.InterruptionEvent{
EventID: fmt.Sprintf("rebalance-recommendation-%x", hash.Sum(nil)),
Expand Down
Loading

0 comments on commit 62e925b

Please sign in to comment.