diff --git a/Makefile b/Makefile index bca8fad0..b9194d90 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ GINKGO = $(BIN_DIR)/ginkgo GUM = $(BIN_DIR)/gum GH = $(BIN_DIR)/gh GOLICENSES = $(BIN_DIR)/go-licenses -HELM_BASE_OPTS ?= --set aws.region=${AWS_REGION},serviceAccount.name=${SERVICE_ACCOUNT_NAME},serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${SERVICE_ACCOUNT_ROLE_ARN} +HELM_BASE_OPTS ?= --set aws.region=${AWS_REGION},serviceAccount.name=${SERVICE_ACCOUNT_NAME},serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${SERVICE_ACCOUNT_ROLE_ARN} \ + --set-string serviceAccount.annotations.eks\\.amazonaws\\.com/sts-regional-endpoints=true GINKGO_BASE_OPTS ?= -r --coverpkg $(shell head -n 1 $(PROJECT_DIR)/go.mod | cut -s -d ' ' -f 2)/pkg/... KODATA = \ cmd/controller/kodata/HEAD \ diff --git a/README.md b/README.md index ee3241a2..fd65ed69 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,8 @@ helm upgrade \ --create-namespace \ --set aws.region= \ --set serviceAccount.name="nth-service-account" \ - --set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn= + --set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn= \ + --set-string serviceAccount.annotations.eks\\.amazonaws\\.com/sts-regional-endpoints=true ``` For a full list of inputs see the Helm chart `README.md`. diff --git a/THIRD_PARTY_LICENSES.md b/THIRD_PARTY_LICENSES.md index 8289a7c7..24ed7359 100644 --- a/THIRD_PARTY_LICENSES.md +++ b/THIRD_PARTY_LICENSES.md @@ -12,8 +12,23 @@ - github.com/PuerkitoBio/purell v1.1.1 [BSD-3-Clause](https://github.com/PuerkitoBio/purell/blob/v1.1.1/LICENSE) - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 [BSD-3-Clause](https://github.com/PuerkitoBio/urlesc/blob/de5bf2ad4578/LICENSE) - github.com/aws/aws-node-termination-handler Unknown [Apache-2.0](https://github.com/aws/aws-node-termination-handler/blob/HEAD/LICENSE) -- github.com/aws/aws-sdk-go v1.38.55 [Apache-2.0](https://github.com/aws/aws-sdk-go/blob/v1.38.55/LICENSE.txt) -- github.com/aws/aws-sdk-go/internal/sync/singleflight v1.38.55 [BSD-3-Clause](https://github.com/aws/aws-sdk-go/blob/v1.38.55/internal/sync/singleflight/LICENSE) +- github.com/aws/aws-sdk-go-v2 v1.17.1 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/v1.17.1/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/config v1.18.3 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/config/v1.18.3/config/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/credentials v1.13.3 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/credentials/v1.13.3/credentials/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/feature/ec2/imds/v1.12.19/feature/ec2/imds/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/internal/configsources/v1.1.25/internal/configsources/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/internal/endpoints/v2.4.19/internal/endpoints/v2/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/internal/ini/v1.3.26/internal/ini/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/internal/sync/singleflight v1.17.1 [BSD-3-Clause](https://github.com/aws/aws-sdk-go-v2/blob/v1.17.1/internal/sync/singleflight/LICENSE) +- github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/autoscaling/v1.24.3/service/autoscaling/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/ec2/v1.74.0/service/ec2/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/internal/presigned-url/v1.9.19/service/internal/presigned-url/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/sqs/v1.19.15/service/sqs/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/sso/v1.11.25/service/sso/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/ssooidc/v1.13.8/service/ssooidc/LICENSE.txt) +- github.com/aws/aws-sdk-go-v2/service/sts v1.17.5 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/sts/v1.17.5/service/sts/LICENSE.txt) +- github.com/aws/smithy-go v1.13.4 [Apache-2.0](https://github.com/aws/smithy-go/blob/v1.13.4/LICENSE) +- github.com/aws/smithy-go/internal/sync/singleflight v1.13.4 [BSD-3-Clause](https://github.com/aws/smithy-go/blob/v1.13.4/internal/sync/singleflight/LICENSE) - github.com/beorn7/perks/quantile v1.0.1 [MIT](https://github.com/beorn7/perks/blob/v1.0.1/LICENSE) - github.com/blang/semver/v4 v4.0.0 [MIT](https://github.com/blang/semver/blob/v4.0.0/v4/LICENSE) - github.com/blendle/zapdriver v1.3.1 [ISC](https://github.com/blendle/zapdriver/blob/v1.3.1/LICENSE) @@ -39,7 +54,7 @@ - github.com/golang/groupcache/lru v0.0.0-20210331224755-41bb18bfe9da [Apache-2.0](https://github.com/golang/groupcache/blob/41bb18bfe9da/LICENSE) - github.com/golang/protobuf v1.5.2 [BSD-3-Clause](https://github.com/golang/protobuf/blob/v1.5.2/LICENSE) - github.com/google/btree v1.0.1 [Apache-2.0](https://github.com/google/btree/blob/v1.0.1/LICENSE) -- github.com/google/go-cmp/cmp v0.5.6 [BSD-3-Clause](https://github.com/google/go-cmp/blob/v0.5.6/LICENSE) +- github.com/google/go-cmp/cmp v0.5.8 [BSD-3-Clause](https://github.com/google/go-cmp/blob/v0.5.8/LICENSE) - github.com/google/gofuzz v1.2.0 [Apache-2.0](https://github.com/google/gofuzz/blob/v1.2.0/LICENSE) - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 [Apache-2.0](https://github.com/google/shlex/blob/e7afc7fbc510/COPYING) - github.com/google/uuid v1.3.0 [BSD-3-Clause](https://github.com/google/uuid/blob/v1.3.0/LICENSE) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index f56cd7b4..1892e604 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -19,7 +19,6 @@ package main import ( "context" "flag" - "fmt" "os" "time" @@ -59,13 +58,10 @@ import ( terminatoradapter "github.com/aws/aws-node-termination-handler/pkg/terminator/adapter" "github.com/aws/aws-node-termination-handler/pkg/webhook" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/ec2metadata" - "github.com/aws/aws-sdk-go/aws/endpoints" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + awscfg "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/sqs" "github.com/go-logr/zapr" //+kubebuilder:scaffold:imports @@ -91,12 +87,12 @@ func init() { func main() { options := parseOptions() - config := ctrl.GetConfigOrDie() - config.UserAgent = "aws-node-termination-handler" - ctx, startInformers := knativeinjection.EnableInjectionOrDie(signals.NewContext(), config) + ctrlConfig := ctrl.GetConfigOrDie() + ctrlConfig.UserAgent = "aws-node-termination-handler" + ctx, startInformers := knativeinjection.EnableInjectionOrDie(signals.NewContext(), ctrlConfig) logger, atomicLevel := sharedmain.SetupLoggerOrDie(ctx, componentName) ctx = logging.WithLogger(ctx, logger) - clientSet := kubernetes.NewForConfigOrDie(config) + clientSet := kubernetes.NewForConfigOrDie(ctrlConfig) cmw := informer.NewInformedWatcher(clientSet, system.Namespace()) ctrl.SetLogger(zapr.NewLogger(logger.Desugar())) @@ -108,7 +104,7 @@ func main() { } startInformers() - mgr, err := ctrl.NewManager(config, ctrl.Options{ + mgr, err := ctrl.NewManager(ctrlConfig, ctrl.Options{ Scheme: scheme, MetricsBindAddress: options.MetricsAddress, Port: 9443, @@ -128,19 +124,19 @@ func main() { } kubeClient := mgr.GetClient() - awsSession, err := newAWSSession(options.AWSRegion) + awsConfig, err := awscfg.LoadDefaultConfig(ctx, awscfg.WithRegion(options.AWSRegion)) if err != nil { - logger.With("error", err).Fatal("failed to initialize AWS session") + logger.With("error", err).Fatal("failed to load AWS configuration") } - sqsClient := sqs.New(awsSession) + sqsClient := sqs.NewFromConfig(awsConfig) if sqsClient == nil { logger.Fatal("failed to create SQS client") } - asgClient := autoscaling.New(awsSession) + asgClient := autoscaling.NewFromConfig(awsConfig) if asgClient == nil { logger.Fatal("failed to create ASG client") } - ec2Client := ec2.New(awsSession) + ec2Client := ec2.NewFromConfig(awsConfig) if ec2Client == nil { logger.Fatal("failed to create EC2 client") } @@ -212,34 +208,6 @@ func parseOptions() Options { return options } -func newAWSSession(awsRegion string) (*session.Session, error) { - config := aws.NewConfig(). - WithRegion(awsRegion). - WithSTSRegionalEndpoint(endpoints.RegionalSTSEndpoint) - sess, err := session.NewSessionWithOptions(session.Options{ - Config: *config, - SharedConfigState: session.SharedConfigEnable, - }) - if err != nil { - return nil, fmt.Errorf("failed to create AWS session: %w", err) - } - - if sess.Config.Region == nil || *sess.Config.Region == "" { - awsRegion, err := ec2metadata.New(sess).Region() - if err != nil { - return nil, fmt.Errorf("failed to get AWS region: %w", err) - } - sess.Config.Region = aws.String(awsRegion) - } - - _, err = sess.Config.Credentials.Get() - if err != nil { - return nil, fmt.Errorf("failed to get AWS session credentials: %w", err) - } - - return sess, nil -} - func indexNodeName(ctx context.Context, indexer client.FieldIndexer) error { return indexer.IndexField(ctx, &v1.Pod{}, "spec.nodeName", func(o client.Object) []string { if o == nil { diff --git a/go.mod b/go.mod index 2820dc4e..28f4e93e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,12 @@ module github.com/aws/aws-node-termination-handler go 1.19 require ( - github.com/aws/aws-sdk-go v1.38.55 + github.com/aws/aws-sdk-go-v2 v1.17.1 + github.com/aws/aws-sdk-go-v2/config v1.18.3 + github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0 + github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15 + github.com/aws/smithy-go v1.13.4 github.com/go-logr/zapr v0.4.0 github.com/onsi/ginkgo/v2 v2.1.3 github.com/onsi/gomega v1.18.1 @@ -31,6 +36,15 @@ require ( github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.3 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.17.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/blendle/zapdriver v1.3.1 // indirect @@ -55,7 +69,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/btree v1.0.1 // indirect - github.com/google/go-cmp v0.5.6 // indirect + github.com/google/go-cmp v0.5.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.3.0 // indirect diff --git a/go.sum b/go.sum index 28f605f9..169921de 100644 --- a/go.sum +++ b/go.sum @@ -106,6 +106,36 @@ github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:l github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.38.55 h1:1Wv5CE1Zy0hJ6MJUQ1ekFiCsNKBK5W69+towYQ1P4Vs= github.com/aws/aws-sdk-go v1.38.55/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/aws/aws-sdk-go-v2 v1.17.1 h1:02c72fDJr87N8RAC2s3Qu0YuvMRZKNZJ9F+lAehCazk= +github.com/aws/aws-sdk-go-v2 v1.17.1/go.mod h1:JLnGeGONAyi2lWXI1p0PCIOIy333JMVK1U7Hf0aRFLw= +github.com/aws/aws-sdk-go-v2/config v1.18.3 h1:3kfBKcX3votFX84dm00U8RGA1sCCh3eRMOGzg5dCWfU= +github.com/aws/aws-sdk-go-v2/config v1.18.3/go.mod h1:BYdrbeCse3ZnOD5+2/VE/nATOK8fEUpBtmPMdKSyhMU= +github.com/aws/aws-sdk-go-v2/credentials v1.13.3 h1:ur+FHdp4NbVIv/49bUjBW+FE7e57HOo03ELodttmagk= +github.com/aws/aws-sdk-go-v2/credentials v1.13.3/go.mod h1:/rOMmqYBcFfNbRPU0iN9IgGqD5+V2yp3iWNmIlz0wI4= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 h1:E3PXZSI3F2bzyj6XxUXdTIfvp425HHhwKsFvmzBwHgs= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19/go.mod h1:VihW95zQpeKQWVPGkwT+2+WJNQV8UXFfMTWdU6VErL8= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 h1:nBO/RFxeq/IS5G9Of+ZrgucRciie2qpLy++3UGZ+q2E= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25/go.mod h1:Zb29PYkf42vVYQY6pvSyJCJcFHlPIiY+YKdPtwnvMkY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 h1:oRHDrwCTVT8ZXi4sr9Ld+EXk7N/KGssOr2ygNeojEhw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19/go.mod h1:6Q0546uHDp421okhmmGfbxzq2hBqbXFNpi4k+Q1JnQA= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 h1:Mza+vlnZr+fPKFKRq/lKGVvM6B/8ZZmNdEopOwSQLms= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26/go.mod h1:Y2OJ+P+MC1u1VKnavT+PshiEuGPyh/7DqxoDNij4/bg= +github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3 h1:VnxU0zK4CNqsy1GiBz/UcWl9J6Qd6YrY34lT+/9Pzsk= +github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3/go.mod h1:1ioJeG7kmYYuqmA8Wsh5AXwjPn9mRKL6F8OOwt/uyBQ= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0 h1:5MCRd9q1yrGoRdYZDxK6y048VNmQ6gKLdCFr+TZsvTY= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0/go.mod h1:zul71QqzR4D1a90/5FloZiAnZ1CtuIjVH7R9MP997+A= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 h1:GE25AWCdNUPh9AOJzI9KIJnja7IwUc1WyUqz/JTyJ/I= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19/go.mod h1:02CP6iuYP+IVnBX5HULVdSAku/85eHB2Y9EsFhrkEwU= +github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15 h1:5PgOVgJWObGxve+0qU7T/C0reU6RxqpNwbuunLT9Vlc= +github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15/go.mod h1:DKX/7/ZiAzHO6p6AhArnGdrV4r+d461weby8KeVtvC4= +github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 h1:GFZitO48N/7EsFDt8fMa5iYdmWqkUDDB3Eje6z3kbG0= +github.com/aws/aws-sdk-go-v2/service/sso v1.11.25/go.mod h1:IARHuzTXmj1C0KS35vboR0FeJ89OkEy1M9mWbK2ifCI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 h1:jcw6kKZrtNfBPJkaHrscDOZoe5gvi9wjudnxvozYFJo= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8/go.mod h1:er2JHN+kBY6FcMfcBBKNGCT3CarImmdFzishsqBmSRI= +github.com/aws/aws-sdk-go-v2/service/sts v1.17.5 h1:60SJ4lhvn///8ygCzYy2l53bFW/Q15bVfyjyAWo6zuw= +github.com/aws/aws-sdk-go-v2/service/sts v1.17.5/go.mod h1:bXcN3koeVYiJcdDU89n3kCYILob7Y34AeLopUbZgLT4= +github.com/aws/smithy-go v1.13.4 h1:/RN2z1txIJWeXeOkzX+Hk/4Uuvv7dWtCjbmVJcrskyk= +github.com/aws/smithy-go v1.13.4/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -361,8 +391,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v27 v27.0.6/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= diff --git a/pkg/event/asgterminate/lifecycleaction/complete.go b/pkg/event/asgterminate/lifecycleaction/complete.go index 34cdcba5..ec773e72 100644 --- a/pkg/event/asgterminate/lifecycleaction/complete.go +++ b/pkg/event/asgterminate/lifecycleaction/complete.go @@ -20,15 +20,14 @@ import ( "context" "errors" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" + "github.com/aws/aws-sdk-go-v2/aws" + awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" ) type ( ASGLifecycleActionCompleter interface { - CompleteLifecycleActionWithContext(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error) + CompleteLifecycleAction(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) } Input struct { @@ -40,16 +39,15 @@ type ( ) func Complete(ctx context.Context, completer ASGLifecycleActionCompleter, input Input) (bool, error) { - if _, err := completer.CompleteLifecycleActionWithContext(ctx, &autoscaling.CompleteLifecycleActionInput{ + if _, err := completer.CompleteLifecycleAction(ctx, &autoscaling.CompleteLifecycleActionInput{ AutoScalingGroupName: aws.String(input.AutoScalingGroupName), LifecycleActionResult: aws.String("CONTINUE"), LifecycleHookName: aws.String(input.LifecycleHookName), LifecycleActionToken: aws.String(input.LifecycleActionToken), InstanceId: aws.String(input.EC2InstanceID), }); err != nil { - var f awserr.RequestFailure - return errors.As(err, &f) && f.StatusCode() != 400, err + e := &awshttp.ResponseError{} + return errors.As(err, &e) && e.HTTPStatusCode() != 400, err } - return false, nil } diff --git a/pkg/event/asgterminate/v1/types.go b/pkg/event/asgterminate/v1/types.go index 6c9aae0d..227d8cb6 100644 --- a/pkg/event/asgterminate/v1/types.go +++ b/pkg/event/asgterminate/v1/types.go @@ -17,11 +17,11 @@ limitations under the License. package v1 import ( - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" + "context" + + "github.com/aws/aws-sdk-go-v2/service/autoscaling" ) type ASGLifecycleActionCompleter interface { - CompleteLifecycleActionWithContext(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error) + CompleteLifecycleAction(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) } diff --git a/pkg/event/asgterminate/v2/types.go b/pkg/event/asgterminate/v2/types.go index 1ce4d963..0b365c60 100644 --- a/pkg/event/asgterminate/v2/types.go +++ b/pkg/event/asgterminate/v2/types.go @@ -17,11 +17,11 @@ limitations under the License. package v2 import ( - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" + "context" + + "github.com/aws/aws-sdk-go-v2/service/autoscaling" ) type ASGLifecycleActionCompleter interface { - CompleteLifecycleActionWithContext(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error) + CompleteLifecycleAction(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) } diff --git a/pkg/logging/sqs/deletemessageinput.go b/pkg/logging/sqs/deletemessageinput.go index 5a65a50e..ebe9b3b9 100644 --- a/pkg/logging/sqs/deletemessageinput.go +++ b/pkg/logging/sqs/deletemessageinput.go @@ -17,24 +17,20 @@ limitations under the License. package sqs import ( - awssqs "github.com/aws/aws-sdk-go/service/sqs" + awssqs "github.com/aws/aws-sdk-go-v2/service/sqs" "go.uber.org/zap/zapcore" ) type deleteMessageInputMarshaler struct { - *awssqs.DeleteMessageInput + awssqs.DeleteMessageInput } -func NewDeleteMessageInputMarshaler(input *awssqs.DeleteMessageInput) zapcore.ObjectMarshaler { +func NewDeleteMessageInputMarshaler(input awssqs.DeleteMessageInput) zapcore.ObjectMarshaler { return deleteMessageInputMarshaler{DeleteMessageInput: input} } func (d deleteMessageInputMarshaler) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if d.DeleteMessageInput == nil { - return nil - } - if d.QueueUrl != nil { enc.AddString("queueUrl", *d.QueueUrl) } diff --git a/pkg/logging/sqs/message.go b/pkg/logging/sqs/message.go index da95227f..00426190 100644 --- a/pkg/logging/sqs/message.go +++ b/pkg/logging/sqs/message.go @@ -17,30 +17,26 @@ limitations under the License. package sqs import ( - awssqs "github.com/aws/aws-sdk-go/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" "go.uber.org/zap/zapcore" ) type messageMarshaler struct { - *awssqs.Message + sqstypes.Message } -func NewMessageMarshaler(msg *awssqs.Message) zapcore.ObjectMarshaler { +func NewMessageMarshaler(msg sqstypes.Message) zapcore.ObjectMarshaler { return messageMarshaler{Message: msg} } func (s messageMarshaler) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if s.Message == nil { - return nil - } - if s.MessageId != nil { enc.AddString("messageId", *s.MessageId) } enc.AddObject("attributes", zapcore.ObjectMarshalerFunc(func(enc zapcore.ObjectEncoder) error { for key, value := range s.Attributes { - enc.AddString(key, *value) + enc.AddString(key, value) } return nil })) diff --git a/pkg/logging/sqs/receivemessagesinput.go b/pkg/logging/sqs/receivemessagesinput.go index c71ef602..c31805a3 100644 --- a/pkg/logging/sqs/receivemessagesinput.go +++ b/pkg/logging/sqs/receivemessagesinput.go @@ -17,7 +17,7 @@ limitations under the License. package sqs import ( - awssqs "github.com/aws/aws-sdk-go/service/sqs" + awssqs "github.com/aws/aws-sdk-go-v2/service/sqs" "go.uber.org/zap/zapcore" ) @@ -41,28 +41,18 @@ func (r receiveMessageInputMarshaler) MarshalLogObject(enc zapcore.ObjectEncoder if r.ReceiveRequestAttemptId != nil { enc.AddString("receiveAttemptId", *r.ReceiveRequestAttemptId) } - if r.VisibilityTimeout != nil { - enc.AddInt64("visibilityTimeout", *r.VisibilityTimeout) - } - if r.WaitTimeSeconds != nil { - enc.AddInt64("waitTimeSeconds", *r.WaitTimeSeconds) - } - if r.MaxNumberOfMessages != nil { - enc.AddInt64("maxNumberOfMessages", *r.MaxNumberOfMessages) - } + enc.AddInt32("visibilityTimeout", r.VisibilityTimeout) + enc.AddInt32("waitTimeSeconds", r.WaitTimeSeconds) + enc.AddInt32("maxNumberOfMessages", r.MaxNumberOfMessages) enc.AddArray("attributeNames", zapcore.ArrayMarshalerFunc(func(enc zapcore.ArrayEncoder) error { for _, attr := range r.AttributeNames { - if attr != nil { - enc.AppendString(*attr) - } + enc.AppendString(string(attr)) } return nil })) enc.AddArray("messageAttributeNames", zapcore.ArrayMarshalerFunc(func(enc zapcore.ArrayEncoder) error { for _, attr := range r.MessageAttributeNames { - if attr != nil { - enc.AppendString(*attr) - } + enc.AppendString(attr) } return nil })) diff --git a/pkg/node/name/getter.go b/pkg/node/name/getter.go index 1f772265..7305073a 100644 --- a/pkg/node/name/getter.go +++ b/pkg/node/name/getter.go @@ -22,14 +22,12 @@ import ( "github.com/aws/aws-node-termination-handler/pkg/logging" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2" ) type ( EC2InstancesDescriber interface { - DescribeInstancesWithContext(aws.Context, *ec2.DescribeInstancesInput, ...request.Option) (*ec2.DescribeInstancesOutput, error) + DescribeInstances(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) } Getter struct { @@ -40,8 +38,8 @@ type ( func (g Getter) GetNodeName(ctx context.Context, instanceID string) (string, error) { ctx = logging.WithLogger(ctx, logging.FromContext(ctx).Named("nodeName")) - result, err := g.DescribeInstancesWithContext(ctx, &ec2.DescribeInstancesInput{ - InstanceIds: []*string{aws.String(instanceID)}, + result, err := g.DescribeInstances(ctx, &ec2.DescribeInstancesInput{ + InstanceIds: []string{instanceID}, }) if err != nil { logging.FromContext(ctx). diff --git a/pkg/sqsmessage/client.go b/pkg/sqsmessage/client.go index 6a334e60..ab63ef5a 100644 --- a/pkg/sqsmessage/client.go +++ b/pkg/sqsmessage/client.go @@ -21,15 +21,14 @@ import ( "github.com/aws/aws-node-termination-handler/pkg/logging" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) type ( SQSClient interface { - ReceiveMessageWithContext(aws.Context, *sqs.ReceiveMessageInput, ...request.Option) (*sqs.ReceiveMessageOutput, error) - DeleteMessageWithContext(aws.Context, *sqs.DeleteMessageInput, ...request.Option) (*sqs.DeleteMessageOutput, error) + ReceiveMessage(context.Context, *sqs.ReceiveMessageInput, ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) + DeleteMessage(context.Context, *sqs.DeleteMessageInput, ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) } Client struct { @@ -37,10 +36,10 @@ type ( } ) -func (c Client) GetSQSMessages(ctx context.Context, params *sqs.ReceiveMessageInput) ([]*sqs.Message, error) { +func (c Client) GetSQSMessages(ctx context.Context, params *sqs.ReceiveMessageInput) ([]sqstypes.Message, error) { ctx = logging.WithLogger(ctx, logging.FromContext(ctx).Named("sqsClient.getMessages")) - result, err := c.ReceiveMessageWithContext(ctx, params) + result, err := c.ReceiveMessage(ctx, params) if err != nil { logging.FromContext(ctx). With("error", err). @@ -54,7 +53,7 @@ func (c Client) GetSQSMessages(ctx context.Context, params *sqs.ReceiveMessageIn func (c Client) DeleteSQSMessage(ctx context.Context, params *sqs.DeleteMessageInput) error { ctx = logging.WithLogger(ctx, logging.FromContext(ctx).Named("sqsClient.deleteMessage")) - _, err := c.DeleteMessageWithContext(ctx, params) + _, err := c.DeleteMessage(ctx, params) if err != nil { logging.FromContext(ctx). With("error", err). diff --git a/pkg/terminator/adapter/parser.go b/pkg/terminator/adapter/parser.go index 4f553573..9d51e483 100644 --- a/pkg/terminator/adapter/parser.go +++ b/pkg/terminator/adapter/parser.go @@ -22,15 +22,15 @@ import ( "github.com/aws/aws-node-termination-handler/pkg/event" "github.com/aws/aws-node-termination-handler/pkg/terminator" - "github.com/aws/aws-sdk-go/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) type EventParser struct { event.Parser } -func (e EventParser) Parse(ctx context.Context, msg *sqs.Message) terminator.Event { - if msg == nil || msg.Body == nil { +func (e EventParser) Parse(ctx context.Context, msg sqstypes.Message) terminator.Event { + if msg.Body == nil { return e.Parser.Parse(ctx, "") } return e.Parser.Parse(ctx, *msg.Body) diff --git a/pkg/terminator/adapter/sqsclient.go b/pkg/terminator/adapter/sqsclient.go index a0abadf9..4ccaeead 100644 --- a/pkg/terminator/adapter/sqsclient.go +++ b/pkg/terminator/adapter/sqsclient.go @@ -23,13 +23,14 @@ import ( "github.com/aws/aws-node-termination-handler/pkg/logging" "github.com/aws/aws-node-termination-handler/pkg/terminator" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) type ( SQSMessageClient interface { - GetSQSMessages(context.Context, *sqs.ReceiveMessageInput) ([]*sqs.Message, error) + GetSQSMessages(context.Context, *sqs.ReceiveMessageInput) ([]sqstypes.Message, error) DeleteSQSMessage(context.Context, *sqs.DeleteMessageInput) error } @@ -46,16 +47,12 @@ type ( func (s SQSMessageClientBuilder) NewSQSClient(terminator *v1alpha1.Terminator) (terminator.SQSClient, error) { receiveMessageInput := sqs.ReceiveMessageInput{ - QueueUrl: aws.String(terminator.Spec.SQS.QueueURL), - MaxNumberOfMessages: aws.Int64(10), - VisibilityTimeout: aws.Int64(20), // Seconds - WaitTimeSeconds: aws.Int64(20), // Seconds, maximum for long polling - AttributeNames: []*string{ - aws.String(sqs.MessageSystemAttributeNameSentTimestamp), - }, - MessageAttributeNames: []*string{ - aws.String(sqs.QueueAttributeNameAll), - }, + QueueUrl: aws.String(terminator.Spec.SQS.QueueURL), + MaxNumberOfMessages: 10, + VisibilityTimeout: 20, // Seconds + WaitTimeSeconds: 20, // Seconds, maximum for long polling + AttributeNames: []sqstypes.QueueAttributeName{sqstypes.QueueAttributeNameAll}, + MessageAttributeNames: []string{string(sqstypes.MessageSystemAttributeNameSentTimestamp)}, } deleteMessageInput := sqs.DeleteMessageInput{ @@ -69,7 +66,7 @@ func (s SQSMessageClientBuilder) NewSQSClient(terminator *v1alpha1.Terminator) ( }, nil } -func (s sqsMessageClient) GetSQSMessages(ctx context.Context) ([]*sqs.Message, error) { +func (s sqsMessageClient) GetSQSMessages(ctx context.Context) ([]sqstypes.Message, error) { ctx = logging.WithLogger(ctx, logging.FromContext(ctx). With("params", logging.NewReceiveMessageInputMarshaler(&s.ReceiveMessageInput)), ) @@ -77,11 +74,11 @@ func (s sqsMessageClient) GetSQSMessages(ctx context.Context) ([]*sqs.Message, e return s.SQSMessageClient.GetSQSMessages(ctx, &s.ReceiveMessageInput) } -func (s sqsMessageClient) DeleteSQSMessage(ctx context.Context, msg *sqs.Message) error { +func (s sqsMessageClient) DeleteSQSMessage(ctx context.Context, msg *sqstypes.Message) error { s.DeleteMessageInput.ReceiptHandle = msg.ReceiptHandle ctx = logging.WithLogger(ctx, logging.FromContext(ctx). - With("params", logging.NewDeleteMessageInputMarshaler(&s.DeleteMessageInput)), + With("params", logging.NewDeleteMessageInputMarshaler(s.DeleteMessageInput)), ) return s.SQSMessageClient.DeleteSQSMessage(ctx, &s.DeleteMessageInput) diff --git a/pkg/terminator/reconciler.go b/pkg/terminator/reconciler.go index 74f7fcf3..154208a0 100644 --- a/pkg/terminator/reconciler.go +++ b/pkg/terminator/reconciler.go @@ -25,7 +25,7 @@ import ( "github.com/aws/aws-node-termination-handler/pkg/logging" "github.com/aws/aws-node-termination-handler/pkg/webhook" - "github.com/aws/aws-sdk-go/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -73,8 +73,8 @@ type ( } SQSClient interface { - GetSQSMessages(context.Context) ([]*sqs.Message, error) - DeleteSQSMessage(context.Context, *sqs.Message) error + GetSQSMessages(context.Context) ([]sqstypes.Message, error) + DeleteSQSMessage(context.Context, *sqstypes.Message) error } SQSClientBuilder interface { @@ -82,7 +82,7 @@ type ( } SQSMessageParser interface { - Parse(context.Context, *sqs.Message) Event + Parse(context.Context, sqstypes.Message) Event } WebhookClient interface { @@ -151,7 +151,7 @@ func (r Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (recon return reconcile.Result{RequeueAfter: r.RequeueInterval}, nil } -func (r Reconciler) handleMessage(ctx context.Context, msg *sqs.Message, terminator *v1alpha1.Terminator, nodeGetter NodeGetter, cordondrainer CordonDrainer, sqsClient SQSClient, webhookRequest webhook.Request) (err error) { +func (r Reconciler) handleMessage(ctx context.Context, msg sqstypes.Message, terminator *v1alpha1.Terminator, nodeGetter NodeGetter, cordondrainer CordonDrainer, sqsClient SQSClient, webhookRequest webhook.Request) (err error) { ctx = logging.WithLogger(ctx, logging.FromContext(ctx).With("sqsMessage", logging.NewMessageMarshaler(msg))) evt := r.Parse(ctx, msg) @@ -181,7 +181,7 @@ func (r Reconciler) handleMessage(ctx context.Context, msg *sqs.Message, termina return err } - return multierr.Append(err, sqsClient.DeleteSQSMessage(ctx, msg)) + return multierr.Append(err, sqsClient.DeleteSQSMessage(ctx, &msg)) } func (r Reconciler) handleInstance(ctx context.Context, ec2InstanceID string, evtAction v1alpha1.Action, nodeGetter NodeGetter, cordondrainer CordonDrainer, webhookRequest webhook.Request) (bool, error) { diff --git a/test/reconciler/asg_lifecycle_v1.go b/test/reconciler/asg_lifecycle_v1.go index 8e9dd7d1..9ba638c0 100644 --- a/test/reconciler/asg_lifecycle_v1.go +++ b/test/reconciler/asg_lifecycle_v1.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -49,7 +49,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -92,7 +92,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", diff --git a/test/reconciler/asg_lifecycle_v2.go b/test/reconciler/asg_lifecycle_v2.go index 47dd8184..6f2fb7be 100644 --- a/test/reconciler/asg_lifecycle_v2.go +++ b/test/reconciler/asg_lifecycle_v2.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -49,7 +49,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -92,7 +92,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", diff --git a/test/reconciler/asg_v1_err.go b/test/reconciler/asg_v1_err.go index 7a0d2163..db5e68ad 100644 --- a/test/reconciler/asg_v1_err.go +++ b/test/reconciler/asg_v1_err.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "errors" "fmt" @@ -26,10 +27,9 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -45,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -58,7 +58,7 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.CompleteASGLifecycleActionFunc = func(_ aws.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { + infra.CompleteASGLifecycleActionFunc = func(_ context.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { return nil, errors.New(errMsg) } diff --git a/test/reconciler/asg_v1_err_ne_400.go b/test/reconciler/asg_v1_err_ne_400.go index dbf7ea6c..8b659d6e 100644 --- a/test/reconciler/asg_v1_err_ne_400.go +++ b/test/reconciler/asg_v1_err_ne_400.go @@ -17,8 +17,9 @@ limitations under the License. package reconciler import ( - "errors" + "context" "fmt" + "net/http" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -26,11 +27,11 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" + smithyhttp "github.com/aws/smithy-go/transport/http" ) var _ = Describe("Reconciliation", func() { @@ -47,7 +48,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -60,8 +61,22 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.CompleteASGLifecycleActionFunc = func(_ aws.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { - return nil, awserr.NewRequestFailure(awserr.New("", errMsg, errors.New(errMsg)), 404, "") + infra.CompleteASGLifecycleActionFunc = func(_ context.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { + return nil, &awshttp.ResponseError{ + ResponseError: &smithyhttp.ResponseError{ + Response: &smithyhttp.Response{ + Response: &http.Response{ + Status: "404 Not Found", + StatusCode: 404, + Proto: "HTTP/1.0", + ProtoMajor: 1, + ProtoMinor: 0, + }, + }, + Err: fmt.Errorf(errMsg), + }, + RequestID: "mock_request_id", + } } result, err = infra.Reconcile() diff --git a/test/reconciler/asg_v2_err.go b/test/reconciler/asg_v2_err.go index e6c75ba6..1ad429ce 100644 --- a/test/reconciler/asg_v2_err.go +++ b/test/reconciler/asg_v2_err.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "errors" "fmt" @@ -26,10 +27,9 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -45,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -58,7 +58,7 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.CompleteASGLifecycleActionFunc = func(_ aws.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { + infra.CompleteASGLifecycleActionFunc = func(_ context.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { return nil, errors.New(errMsg) } diff --git a/test/reconciler/asg_v2_err_ne_400.go b/test/reconciler/asg_v2_err_ne_400.go index 07e29dcc..1e4b6ad7 100644 --- a/test/reconciler/asg_v2_err_ne_400.go +++ b/test/reconciler/asg_v2_err_ne_400.go @@ -17,20 +17,21 @@ limitations under the License. package reconciler import ( - "errors" + "context" "fmt" + "net/http" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/aws/aws-node-termination-handler/test/reconciler/mock" + smithyhttp "github.com/aws/smithy-go/transport/http" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -46,7 +47,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -59,8 +60,22 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.CompleteASGLifecycleActionFunc = func(_ aws.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { - return nil, awserr.NewRequestFailure(awserr.New("", errMsg, errors.New(errMsg)), 404, "") + infra.CompleteASGLifecycleActionFunc = func(_ context.Context, _ *autoscaling.CompleteLifecycleActionInput, _ ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { + return nil, &awshttp.ResponseError{ + ResponseError: &smithyhttp.ResponseError{ + Response: &smithyhttp.Response{ + Response: &http.Response{ + Status: "404 Not Found", + StatusCode: 404, + Proto: "HTTP/1.0", + ProtoMajor: 1, + ProtoMinor: 0, + }, + }, + Err: fmt.Errorf(errMsg), + }, + RequestID: "mock_request_id", + } } result, err = infra.Reconcile() diff --git a/test/reconciler/complete_asg_lifecycle.go b/test/reconciler/complete_asg_lifecycle.go index 9d2314a7..cad11bdc 100644 --- a/test/reconciler/complete_asg_lifecycle.go +++ b/test/reconciler/complete_asg_lifecycle.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "fmt" . "github.com/onsi/ginkgo/v2" @@ -24,10 +25,9 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -47,7 +47,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -64,7 +64,7 @@ var _ = Describe("Reconciliation", func() { }) defaultCompleteASGLifecycleActionFunc := infra.CompleteASGLifecycleActionFunc - infra.CompleteASGLifecycleActionFunc = func(ctx aws.Context, in *autoscaling.CompleteLifecycleActionInput, options ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { + infra.CompleteASGLifecycleActionFunc = func(ctx context.Context, in *autoscaling.CompleteLifecycleActionInput, options ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { input = in return defaultCompleteASGLifecycleActionFunc(ctx, in, options...) } diff --git a/test/reconciler/cordon_err.go b/test/reconciler/cordon_err.go index 256da8d4..524bc658 100644 --- a/test/reconciler/cordon_err.go +++ b/test/reconciler/cordon_err.go @@ -29,8 +29,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -46,7 +46,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/cordon_node.go b/test/reconciler/cordon_node.go index e3a998f1..e997fe29 100644 --- a/test/reconciler/cordon_node.go +++ b/test/reconciler/cordon_node.go @@ -28,8 +28,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -67,7 +67,7 @@ var _ = Describe("Reconciliation", func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/drain_err.go b/test/reconciler/drain_err.go index e8fdd24b..50812785 100644 --- a/test/reconciler/drain_err.go +++ b/test/reconciler/drain_err.go @@ -28,8 +28,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -45,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/drain_node.go b/test/reconciler/drain_node.go index 2e9b9607..e4c34d4b 100644 --- a/test/reconciler/drain_node.go +++ b/test/reconciler/drain_node.go @@ -27,8 +27,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -66,7 +66,7 @@ var _ = Describe("Reconciliation", func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/ec2_res_empty_dns.go b/test/reconciler/ec2_res_empty_dns.go index 7f1013d9..b79810d7 100644 --- a/test/reconciler/ec2_res_empty_dns.go +++ b/test/reconciler/ec2_res_empty_dns.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "fmt" . "github.com/onsi/ginkgo/v2" @@ -26,10 +27,10 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -44,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -56,11 +57,11 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.DescribeEC2InstancesFunc = func(_ aws.Context, _ *ec2.DescribeInstancesInput, _ ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + infra.DescribeEC2InstancesFunc = func(_ context.Context, _ *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return &ec2.DescribeInstancesOutput{ - Reservations: []*ec2.Reservation{ + Reservations: []ec2types.Reservation{ { - Instances: []*ec2.Instance{ + Instances: []ec2types.Instance{ {PrivateDnsName: aws.String("")}, }, }, diff --git a/test/reconciler/ec2_res_no_dns.go b/test/reconciler/ec2_res_no_dns.go index 09511ae8..5879f7f1 100644 --- a/test/reconciler/ec2_res_no_dns.go +++ b/test/reconciler/ec2_res_no_dns.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "fmt" . "github.com/onsi/ginkgo/v2" @@ -26,10 +27,10 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -44,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -56,11 +57,11 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.DescribeEC2InstancesFunc = func(_ aws.Context, _ *ec2.DescribeInstancesInput, _ ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + infra.DescribeEC2InstancesFunc = func(_ context.Context, _ *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return &ec2.DescribeInstancesOutput{ - Reservations: []*ec2.Reservation{ + Reservations: []ec2types.Reservation{ { - Instances: []*ec2.Instance{ + Instances: []ec2types.Instance{ {PrivateDnsName: nil}, }, }, diff --git a/test/reconciler/ec2_res_no_inst.go b/test/reconciler/ec2_res_no_inst.go index ed3b9f92..b1a31b69 100644 --- a/test/reconciler/ec2_res_no_inst.go +++ b/test/reconciler/ec2_res_no_inst.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "fmt" . "github.com/onsi/ginkgo/v2" @@ -26,10 +27,10 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -44,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -56,10 +57,10 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.DescribeEC2InstancesFunc = func(_ aws.Context, _ *ec2.DescribeInstancesInput, _ ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + infra.DescribeEC2InstancesFunc = func(_ context.Context, _ *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return &ec2.DescribeInstancesOutput{ - Reservations: []*ec2.Reservation{ - {Instances: []*ec2.Instance{}}, + Reservations: []ec2types.Reservation{ + {Instances: []ec2types.Instance{}}, }, }, nil } diff --git a/test/reconciler/empty_msg.go b/test/reconciler/empty_msg.go index 41e7f66e..3d37cf7c 100644 --- a/test/reconciler/empty_msg.go +++ b/test/reconciler/empty_msg.go @@ -24,8 +24,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -40,7 +40,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(""), }) diff --git a/test/reconciler/get_ec2_res_err.go b/test/reconciler/get_ec2_res_err.go index c3d3e384..4d564b97 100644 --- a/test/reconciler/get_ec2_res_err.go +++ b/test/reconciler/get_ec2_res_err.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "errors" "fmt" @@ -27,10 +28,9 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -46,7 +46,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -58,7 +58,7 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.DescribeEC2InstancesFunc = func(_ aws.Context, _ *ec2.DescribeInstancesInput, _ ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + infra.DescribeEC2InstancesFunc = func(_ context.Context, _ *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return nil, errors.New(errMsg) } diff --git a/test/reconciler/get_node_err.go b/test/reconciler/get_node_err.go index ac1228ab..66311645 100644 --- a/test/reconciler/get_node_err.go +++ b/test/reconciler/get_node_err.go @@ -31,8 +31,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -48,7 +48,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/get_sqs_msg.go b/test/reconciler/get_sqs_msg.go index b4e00896..44409fe5 100644 --- a/test/reconciler/get_sqs_msg.go +++ b/test/reconciler/get_sqs_msg.go @@ -17,26 +17,27 @@ limitations under the License. package reconciler import ( + "context" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { When("getting messages from a terminator's SQS queue", func() { const ( - maxNumberOfMessages = int64(10) - visibilityTimeoutSeconds = int64(20) - waitTimeSeconds = int64(20) + maxNumberOfMessages = int32(10) + visibilityTimeoutSeconds = int32(20) + waitTimeSeconds = int32(20) ) var ( - attributeNames = []string{sqs.MessageSystemAttributeNameSentTimestamp} - messageAttributeNames = []string{sqs.QueueAttributeNameAll} + attributeNames = []sqstypes.QueueAttributeName{sqstypes.QueueAttributeNameAll} + messageAttributeNames = []string{string(sqstypes.MessageSystemAttributeNameSentTimestamp)} input *sqs.ReceiveMessageInput infra *mock.Infrastructure ) @@ -49,7 +50,7 @@ var _ = Describe("Reconciliation", func() { terminator.Spec.SQS.QueueURL = mock.QueueURL defaultReceiveSQSMessageFunc := infra.ReceiveSQSMessageFunc - infra.ReceiveSQSMessageFunc = func(ctx aws.Context, in *sqs.ReceiveMessageInput, options ...awsrequest.Option) (*sqs.ReceiveMessageOutput, error) { + infra.ReceiveSQSMessageFunc = func(ctx context.Context, in *sqs.ReceiveMessageInput, options ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) { input = in return defaultReceiveSQSMessageFunc(ctx, in, options...) } @@ -62,24 +63,24 @@ var _ = Describe("Reconciliation", func() { for i, attrName := range input.AttributeNames { Expect(attrName).ToNot(BeNil()) - Expect(*attrName).To(Equal(attributeNames[i])) + Expect(attrName).To(Equal(attributeNames[i])) } for i, attrName := range input.MessageAttributeNames { Expect(attrName).ToNot(BeNil()) - Expect(*attrName).To(Equal(messageAttributeNames[i])) + Expect(attrName).To(Equal(messageAttributeNames[i])) } Expect(input.MaxNumberOfMessages).ToNot(BeNil()) - Expect(*input.MaxNumberOfMessages).To(Equal(maxNumberOfMessages)) + Expect(input.MaxNumberOfMessages).To(Equal(maxNumberOfMessages)) Expect(input.QueueUrl).ToNot(BeNil()) Expect(*input.QueueUrl).To(Equal(mock.QueueURL)) Expect(input.VisibilityTimeout).ToNot(BeNil()) - Expect(*input.VisibilityTimeout).To(Equal(visibilityTimeoutSeconds)) + Expect(input.VisibilityTimeout).To(Equal(visibilityTimeoutSeconds)) Expect(input.WaitTimeSeconds).ToNot(BeNil()) - Expect(*input.WaitTimeSeconds).To(Equal(waitTimeSeconds)) + Expect(input.WaitTimeSeconds).To(Equal(waitTimeSeconds)) }) }) }) diff --git a/test/reconciler/get_sqs_msg_err.go b/test/reconciler/get_sqs_msg_err.go index 80a546b8..3902a361 100644 --- a/test/reconciler/get_sqs_msg_err.go +++ b/test/reconciler/get_sqs_msg_err.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "errors" . "github.com/onsi/ginkgo/v2" @@ -26,9 +27,7 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/service/sqs" ) var _ = Describe("Reconciliation", func() { @@ -42,7 +41,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra = mock.NewInfrastructure() - infra.ReceiveSQSMessageFunc = func(_ aws.Context, _ *sqs.ReceiveMessageInput, _ ...awsrequest.Option) (*sqs.ReceiveMessageOutput, error) { + infra.ReceiveSQSMessageFunc = func(_ context.Context, _ *sqs.ReceiveMessageInput, _ ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) { return nil, errors.New(errMsg) } diff --git a/test/reconciler/mock/asgclient.go b/test/reconciler/mock/asgclient.go index 661018c2..39dc1a1b 100644 --- a/test/reconciler/mock/asgclient.go +++ b/test/reconciler/mock/asgclient.go @@ -17,17 +17,17 @@ limitations under the License. package mock import ( - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" + "context" + + "github.com/aws/aws-sdk-go-v2/service/autoscaling" ) type ( - CompleteASGLifecycleActionFunc = func(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error) + CompleteASGLifecycleActionFunc = func(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) ASGClient CompleteASGLifecycleActionFunc ) -func (a ASGClient) CompleteLifecycleActionWithContext(ctx aws.Context, input *autoscaling.CompleteLifecycleActionInput, options ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { +func (a ASGClient) CompleteLifecycleAction(ctx context.Context, input *autoscaling.CompleteLifecycleActionInput, options ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { return a(ctx, input, options...) } diff --git a/test/reconciler/mock/ec2client.go b/test/reconciler/mock/ec2client.go index 8ce22faa..1049ecb0 100644 --- a/test/reconciler/mock/ec2client.go +++ b/test/reconciler/mock/ec2client.go @@ -17,17 +17,17 @@ limitations under the License. package mock import ( - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" + "context" + + "github.com/aws/aws-sdk-go-v2/service/ec2" ) type ( - DescribeEC2InstancesFunc = func(aws.Context, *ec2.DescribeInstancesInput, ...request.Option) (*ec2.DescribeInstancesOutput, error) + DescribeEC2InstancesFunc = func(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) EC2Client DescribeEC2InstancesFunc ) -func (e EC2Client) DescribeInstancesWithContext(ctx aws.Context, input *ec2.DescribeInstancesInput, options ...request.Option) (*ec2.DescribeInstancesOutput, error) { +func (e EC2Client) DescribeInstances(ctx context.Context, input *ec2.DescribeInstancesInput, options ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return e(ctx, input, options...) } diff --git a/test/reconciler/mock/infrastructure.go b/test/reconciler/mock/infrastructure.go index f6d895cd..aa27ef91 100644 --- a/test/reconciler/mock/infrastructure.go +++ b/test/reconciler/mock/infrastructure.go @@ -56,11 +56,12 @@ import ( terminatoradapter "github.com/aws/aws-node-termination-handler/pkg/terminator/adapter" "github.com/aws/aws-node-termination-handler/pkg/webhook" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/autoscaling" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + "github.com/aws/aws-sdk-go-v2/service/ec2" + ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/aws/aws-sdk-go-v2/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) type ( @@ -77,9 +78,9 @@ type ( ASGLifecycleActions map[EC2InstanceID]State // Maps an EC2 instance id to the corresponding reservation for a node // in the cluster. - EC2Reservations map[EC2InstanceID]*ec2.Reservation + EC2Reservations map[EC2InstanceID]ec2types.Reservation // Maps a queue URL to a list of messages waiting to be fetched. - SQSQueues map[SQSQueueURL][]*sqs.Message + SQSQueues map[SQSQueueURL][]sqstypes.Message // Output variables // These variables may be modified during reconciliation and should be @@ -157,7 +158,7 @@ func NewInfrastructure() *Infrastructure { infra.TerminatorNamespaceName = types.NamespacedName{Namespace: "test", Name: "foo"} infra.Request = reconcile.Request{NamespacedName: infra.TerminatorNamespaceName} - infra.SQSQueues = map[SQSQueueURL][]*sqs.Message{QueueURL: {}} + infra.SQSQueues = map[SQSQueueURL][]sqstypes.Message{QueueURL: {}} infra.Terminators = map[types.NamespacedName]*v1alpha1.Terminator{ // For convenience create a terminator that points to the sqs queue. infra.TerminatorNamespaceName: { @@ -169,7 +170,7 @@ func NewInfrastructure() *Infrastructure { }, } infra.Nodes = map[types.NamespacedName]*v1.Node{} - infra.EC2Reservations = map[EC2InstanceID]*ec2.Reservation{} + infra.EC2Reservations = map[EC2InstanceID]ec2types.Reservation{} infra.CordonedNodes = map[NodeName]bool{} infra.DrainedNodes = map[NodeName]bool{} @@ -185,28 +186,25 @@ func NewInfrastructure() *Infrastructure { // 2. Setup stub clients. - infra.DescribeEC2InstancesFunc = func(ctx aws.Context, input *ec2.DescribeInstancesInput, _ ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + infra.DescribeEC2InstancesFunc = func(ctx context.Context, input *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { if err := ctx.Err(); err != nil { return nil, err } output := ec2.DescribeInstancesOutput{} for _, instanceID := range input.InstanceIds { - if instanceID == nil { - continue - } - if reservation, found := infra.EC2Reservations[*instanceID]; found { + if reservation, found := infra.EC2Reservations[instanceID]; found { output.Reservations = append(output.Reservations, reservation) } } return &output, nil } - ec2Client := EC2Client(func(ctx aws.Context, input *ec2.DescribeInstancesInput, options ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + ec2Client := EC2Client(func(ctx context.Context, input *ec2.DescribeInstancesInput, options ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return infra.DescribeEC2InstancesFunc(ctx, input, options...) }) - infra.CompleteASGLifecycleActionFunc = func(ctx aws.Context, input *autoscaling.CompleteLifecycleActionInput, _ ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { + infra.CompleteASGLifecycleActionFunc = func(ctx context.Context, input *autoscaling.CompleteLifecycleActionInput, _ ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { if err := ctx.Err(); err != nil { return nil, err } @@ -218,11 +216,11 @@ func NewInfrastructure() *Infrastructure { return &autoscaling.CompleteLifecycleActionOutput{}, nil } - asgClient := ASGClient(func(ctx aws.Context, input *autoscaling.CompleteLifecycleActionInput, options ...awsrequest.Option) (*autoscaling.CompleteLifecycleActionOutput, error) { + asgClient := ASGClient(func(ctx context.Context, input *autoscaling.CompleteLifecycleActionInput, options ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error) { return infra.CompleteASGLifecycleActionFunc(ctx, input, options...) }) - infra.ReceiveSQSMessageFunc = func(ctx aws.Context, input *sqs.ReceiveMessageInput, options ...awsrequest.Option) (*sqs.ReceiveMessageOutput, error) { + infra.ReceiveSQSMessageFunc = func(ctx context.Context, input *sqs.ReceiveMessageInput, options ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) { if err := ctx.Err(); err != nil { return nil, err } @@ -231,10 +229,10 @@ func NewInfrastructure() *Infrastructure { messages, found := infra.SQSQueues[*input.QueueUrl] Expect(found).To(BeTrue(), "SQS queue does not exist: %q", *input.QueueUrl) - return &sqs.ReceiveMessageOutput{Messages: append([]*sqs.Message{}, messages...)}, nil + return &sqs.ReceiveMessageOutput{Messages: append([]sqstypes.Message{}, messages...)}, nil } - infra.DeleteSQSMessageFunc = func(ctx aws.Context, input *sqs.DeleteMessageInput, options ...awsrequest.Option) (*sqs.DeleteMessageOutput, error) { + infra.DeleteSQSMessageFunc = func(ctx context.Context, input *sqs.DeleteMessageInput, options ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) { if err := ctx.Err(); err != nil { return nil, err } @@ -243,7 +241,7 @@ func NewInfrastructure() *Infrastructure { queue, found := infra.SQSQueues[*input.QueueUrl] Expect(found).To(BeTrue(), "SQS queue does not exist: %q", *input.QueueUrl) - updatedQueue := make([]*sqs.Message, 0, len(queue)) + updatedQueue := make([]sqstypes.Message, 0, len(queue)) for i, m := range queue { if m.ReceiptHandle == input.ReceiptHandle { updatedQueue = append(updatedQueue, queue[:i]...) @@ -257,10 +255,10 @@ func NewInfrastructure() *Infrastructure { } sqsClient := SQSClient{ - ReceiveSQSMessageFunc: func(ctx aws.Context, input *sqs.ReceiveMessageInput, options ...awsrequest.Option) (*sqs.ReceiveMessageOutput, error) { + ReceiveSQSMessageFunc: func(ctx context.Context, input *sqs.ReceiveMessageInput, options ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) { return infra.ReceiveSQSMessageFunc(ctx, input, options...) }, - DeleteSQSMessageFunc: func(ctx aws.Context, input *sqs.DeleteMessageInput, options ...awsrequest.Option) (*sqs.DeleteMessageOutput, error) { + DeleteSQSMessageFunc: func(ctx context.Context, input *sqs.DeleteMessageInput, options ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) { return infra.DeleteSQSMessageFunc(ctx, input, options...) }, } @@ -374,8 +372,8 @@ func (m *Infrastructure) ResizeCluster(newNodeCount uint) { instanceID := fmt.Sprintf("instance-%d", currNodeCount) m.InstanceIDs = append(m.InstanceIDs, instanceID) - m.EC2Reservations[instanceID] = &ec2.Reservation{ - Instances: []*ec2.Instance{ + m.EC2Reservations[instanceID] = ec2types.Reservation{ + Instances: []ec2types.Instance{ {PrivateDnsName: aws.String(nodeName)}, }, } diff --git a/test/reconciler/mock/sqsclient.go b/test/reconciler/mock/sqsclient.go index b5fdbbfb..b3d8ff9c 100644 --- a/test/reconciler/mock/sqsclient.go +++ b/test/reconciler/mock/sqsclient.go @@ -17,14 +17,14 @@ limitations under the License. package mock import ( - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/sqs" + "context" + + "github.com/aws/aws-sdk-go-v2/service/sqs" ) type ( - ReceiveSQSMessageFunc = func(aws.Context, *sqs.ReceiveMessageInput, ...request.Option) (*sqs.ReceiveMessageOutput, error) - DeleteSQSMessageFunc = func(aws.Context, *sqs.DeleteMessageInput, ...request.Option) (*sqs.DeleteMessageOutput, error) + ReceiveSQSMessageFunc = func(context.Context, *sqs.ReceiveMessageInput, ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) + DeleteSQSMessageFunc = func(context.Context, *sqs.DeleteMessageInput, ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) SQSClient struct { ReceiveSQSMessageFunc @@ -32,10 +32,10 @@ type ( } ) -func (s SQSClient) ReceiveMessageWithContext(ctx aws.Context, input *sqs.ReceiveMessageInput, options ...request.Option) (*sqs.ReceiveMessageOutput, error) { +func (s SQSClient) ReceiveMessage(ctx context.Context, input *sqs.ReceiveMessageInput, options ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) { return s.ReceiveSQSMessageFunc(ctx, input, options...) } -func (s SQSClient) DeleteMessageWithContext(ctx aws.Context, input *sqs.DeleteMessageInput, options ...request.Option) (*sqs.DeleteMessageOutput, error) { +func (s SQSClient) DeleteMessage(ctx context.Context, input *sqs.DeleteMessageInput, options ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) { return s.DeleteSQSMessageFunc(ctx, input, options...) } diff --git a/test/reconciler/msg_no_body.go b/test/reconciler/msg_no_body.go index 70e0bc6c..72cf377f 100644 --- a/test/reconciler/msg_no_body.go +++ b/test/reconciler/msg_no_body.go @@ -23,8 +23,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -39,7 +39,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), }) diff --git a/test/reconciler/msg_parse_error.go b/test/reconciler/msg_parse_error.go index 29caaa33..1ce453ed 100644 --- a/test/reconciler/msg_parse_error.go +++ b/test/reconciler/msg_parse_error.go @@ -23,8 +23,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -39,7 +39,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(`{ "source": "test.suite", diff --git a/test/reconciler/multiple_msgs.go b/test/reconciler/multiple_msgs.go index 4fa443ad..98d82121 100644 --- a/test/reconciler/multiple_msgs.go +++ b/test/reconciler/multiple_msgs.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -42,7 +42,7 @@ var _ = Describe("Reconciliation", func() { infra.ResizeCluster(12) infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -54,7 +54,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[1])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-2"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -66,7 +66,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[2])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-3"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -77,7 +77,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[3])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-4"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.health", @@ -93,7 +93,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[4], infra.InstanceIDs[5])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-5"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -104,7 +104,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[6])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-6"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -116,7 +116,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[7])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-7"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -128,7 +128,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[8])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-8"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -140,7 +140,7 @@ var _ = Describe("Reconciliation", func() { } }`, infra.InstanceIDs[9])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-9"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/no_ec2_res.go b/test/reconciler/no_ec2_res.go index f105f2b5..e70415a5 100644 --- a/test/reconciler/no_ec2_res.go +++ b/test/reconciler/no_ec2_res.go @@ -17,6 +17,7 @@ limitations under the License. package reconciler import ( + "context" "fmt" . "github.com/onsi/ginkgo/v2" @@ -26,10 +27,10 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -44,7 +45,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -56,9 +57,9 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.DescribeEC2InstancesFunc = func(_ aws.Context, _ *ec2.DescribeInstancesInput, _ ...awsrequest.Option) (*ec2.DescribeInstancesOutput, error) { + infra.DescribeEC2InstancesFunc = func(_ context.Context, _ *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { return &ec2.DescribeInstancesOutput{ - Reservations: []*ec2.Reservation{}, + Reservations: []ec2types.Reservation{}, }, nil } diff --git a/test/reconciler/rebalance_rec.go b/test/reconciler/rebalance_rec.go index 15375e32..0185a9a5 100644 --- a/test/reconciler/rebalance_rec.go +++ b/test/reconciler/rebalance_rec.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -41,7 +41,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/scheduled_change.go b/test/reconciler/scheduled_change.go index f6190a91..86b390b8 100644 --- a/test/reconciler/scheduled_change.go +++ b/test/reconciler/scheduled_change.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -49,7 +49,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(4) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.health", @@ -97,7 +97,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(4) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.health", @@ -133,7 +133,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(4) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.health", diff --git a/test/reconciler/spot_itn.go b/test/reconciler/spot_itn.go index 761c8c60..630b5b12 100644 --- a/test/reconciler/spot_itn.go +++ b/test/reconciler/spot_itn.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -41,7 +41,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/sqs_msg_delete_err.go b/test/reconciler/sqs_msg_delete_err.go index f3ec7a17..ba5c669b 100644 --- a/test/reconciler/sqs_msg_delete_err.go +++ b/test/reconciler/sqs_msg_delete_err.go @@ -28,9 +28,9 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - awsrequest "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/sqs" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -46,7 +46,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -58,7 +58,7 @@ var _ = Describe("Reconciliation", func() { }`, infra.InstanceIDs[1])), }) - infra.DeleteSQSMessageFunc = func(_ context.Context, _ *sqs.DeleteMessageInput, _ ...awsrequest.Option) (*sqs.DeleteMessageOutput, error) { + infra.DeleteSQSMessageFunc = func(_ context.Context, _ *sqs.DeleteMessageInput, _ ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) { return nil, errors.New(errMsg) } diff --git a/test/reconciler/state_change.go b/test/reconciler/state_change.go index e2e82c9a..2de96b75 100644 --- a/test/reconciler/state_change.go +++ b/test/reconciler/state_change.go @@ -25,8 +25,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -49,7 +49,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -81,7 +81,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -113,7 +113,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -145,7 +145,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -177,7 +177,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/terminator_evt_cfg.go b/test/reconciler/terminator_evt_cfg.go index 994476fe..fc46cd44 100644 --- a/test/reconciler/terminator_evt_cfg.go +++ b/test/reconciler/terminator_evt_cfg.go @@ -26,8 +26,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -53,7 +53,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.AutoScalingTermination = "Cordon" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -102,7 +102,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.AutoScalingTermination = "NoAction" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -148,7 +148,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.AutoScalingTermination = "Cordon" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -197,7 +197,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.AutoScalingTermination = "NoAction" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.autoscaling", @@ -243,7 +243,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.RebalanceRecommendation = "Cordon" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -280,7 +280,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.RebalanceRecommendation = "NoAction" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -314,7 +314,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.ScheduledChange = "Cordon" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.health", @@ -362,7 +362,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.ScheduledChange = "NoAction" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.health", @@ -401,7 +401,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.SpotInterruption = "Cordon" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -443,7 +443,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.SpotInterruption = "NoAction" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -477,7 +477,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.StateChange = "Cordon" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -515,7 +515,7 @@ var _ = Describe("Reconciliation", func() { terminator := infra.Terminators[infra.TerminatorNamespaceName] terminator.Spec.Events.StateChange = "NoAction" - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/terminator_node_selector.go b/test/reconciler/terminator_node_selector.go index d9ba480a..1338a3cf 100644 --- a/test/reconciler/terminator_node_selector.go +++ b/test/reconciler/terminator_node_selector.go @@ -29,8 +29,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -66,7 +66,7 @@ var _ = Describe("Reconciliation", func() { terminator.Spec.MatchLabels = client.MatchingLabels{labelName: labelValue} - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", @@ -105,7 +105,7 @@ var _ = Describe("Reconciliation", func() { terminator.Spec.MatchLabels = client.MatchingLabels{labelName: labelValue} - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "source": "aws.ec2", diff --git a/test/reconciler/terminator_webhook_cfg.go b/test/reconciler/terminator_webhook_cfg.go index b89a0597..5371d986 100644 --- a/test/reconciler/terminator_webhook_cfg.go +++ b/test/reconciler/terminator_webhook_cfg.go @@ -33,8 +33,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -82,7 +82,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "id": "%s", @@ -138,7 +138,7 @@ var _ = Describe("Reconciliation", func() { infra.ResizeCluster(5) infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "id": "%s", @@ -151,7 +151,7 @@ var _ = Describe("Reconciliation", func() { } }`, msgIDs[0], msgTimes[0], infra.InstanceIDs[1])), }, - &sqs.Message{ + sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "id": "%s", @@ -212,7 +212,7 @@ var _ = Describe("Reconciliation", func() { BeforeEach(func() { infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(fmt.Sprintf(`{ "id": "%s", diff --git a/test/reconciler/unrecognized_msg.go b/test/reconciler/unrecognized_msg.go index 5f503611..e75ae6be 100644 --- a/test/reconciler/unrecognized_msg.go +++ b/test/reconciler/unrecognized_msg.go @@ -24,8 +24,8 @@ import ( "github.com/aws/aws-node-termination-handler/test/reconciler/mock" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go-v2/aws" + sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ = Describe("Reconciliation", func() { @@ -40,7 +40,7 @@ var _ = Describe("Reconciliation", func() { infra = mock.NewInfrastructure() infra.ResizeCluster(3) - infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], &sqs.Message{ + infra.SQSQueues[mock.QueueURL] = append(infra.SQSQueues[mock.QueueURL], sqstypes.Message{ ReceiptHandle: aws.String("msg-1"), Body: aws.String(`{ "source": "test.suite",