Skip to content

Commit 02d5980

Browse files
committed
Migrate elb to AWS SDK v2
1 parent 63b8bcf commit 02d5980

39 files changed

+1872
-5717
lines changed

controllers/awscluster_controller.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type AWSClusterReconciler struct {
8080
ExternalResourceGC bool
8181
AlternativeGCStrategy bool
8282
TagUnmanagedNetworkResources bool
83+
MaxWaitActiveUpdateDelete time.Duration
8384
}
8485

8586
// getEC2Service factory func is added for testing purpose so that we can inject mocked EC2Service to the AWSClusterReconciler.
@@ -178,6 +179,7 @@ func (r *AWSClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
178179
ControllerName: "awscluster",
179180
Endpoints: r.Endpoints,
180181
TagUnmanagedNetworkResources: r.TagUnmanagedNetworkResources,
182+
MaxWaitActiveUpdateDelete: r.MaxWaitActiveUpdateDelete,
181183
})
182184
if err != nil {
183185
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
@@ -247,7 +249,7 @@ func (r *AWSClusterReconciler) reconcileDelete(ctx context.Context, clusterScope
247249
allErrs = append(allErrs, errors.Wrapf(err, "error deleting S3 Bucket"))
248250
}
249251

250-
if err := elbsvc.DeleteLoadbalancers(); err != nil {
252+
if err := elbsvc.DeleteLoadbalancers(ctx); err != nil {
251253
allErrs = append(allErrs, errors.Wrapf(err, "error deleting load balancers"))
252254
}
253255

@@ -279,7 +281,7 @@ func (r *AWSClusterReconciler) reconcileDelete(ctx context.Context, clusterScope
279281
return reconcile.Result{}, nil
280282
}
281283

282-
func (r *AWSClusterReconciler) reconcileLoadBalancer(clusterScope *scope.ClusterScope, awsCluster *infrav1.AWSCluster) (*time.Duration, error) {
284+
func (r *AWSClusterReconciler) reconcileLoadBalancer(ctx context.Context, clusterScope *scope.ClusterScope, awsCluster *infrav1.AWSCluster) (*time.Duration, error) {
283285
retryAfterDuration := 15 * time.Second
284286
if clusterScope.AWSCluster.Spec.ControlPlaneLoadBalancer.LoadBalancerType == infrav1.LoadBalancerTypeDisabled {
285287
clusterScope.Debug("load balancer reconciliation shifted to external provider, checking external endpoint")
@@ -289,7 +291,7 @@ func (r *AWSClusterReconciler) reconcileLoadBalancer(clusterScope *scope.Cluster
289291

290292
elbService := r.getELBService(clusterScope)
291293

292-
if err := elbService.ReconcileLoadbalancers(); err != nil {
294+
if err := elbService.ReconcileLoadbalancers(ctx); err != nil {
293295
clusterScope.Error(err, "failed to reconcile load balancer")
294296
conditions.MarkFalse(awsCluster, infrav1.LoadBalancerReadyCondition, infrav1.LoadBalancerFailedReason, infrautilconditions.ErrorConditionAfterInit(clusterScope.ClusterObj()), "%s", err.Error())
295297
return nil, err
@@ -354,7 +356,7 @@ func (r *AWSClusterReconciler) reconcileNormal(ctx context.Context, clusterScope
354356
}
355357
}
356358

357-
if requeueAfter, err := r.reconcileLoadBalancer(clusterScope, awsCluster); err != nil {
359+
if requeueAfter, err := r.reconcileLoadBalancer(ctx, clusterScope, awsCluster); err != nil {
358360
return reconcile.Result{}, err
359361
} else if requeueAfter != nil {
360362
return reconcile.Result{RequeueAfter: *requeueAfter}, err

controllers/awscluster_controller_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import (
2121
"testing"
2222
"time"
2323

24-
"github.com/aws/aws-sdk-go/aws"
24+
"github.com/aws/aws-sdk-go-v2/aws"
25+
elb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
26+
elbtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
2527
"github.com/aws/aws-sdk-go/service/ec2"
26-
"github.com/aws/aws-sdk-go/service/elb"
2728
"github.com/golang/mock/gomock"
2829
. "github.com/onsi/gomega"
2930
"github.com/pkg/errors"
@@ -1379,26 +1380,26 @@ func mockedCallsForMissingEverything(m *mocks.MockEC2APIMockRecorder, e *mocks.M
13791380
SubnetId: aws.String("subnet-2"),
13801381
})).Return(&ec2.AssociateRouteTableOutput{}, nil)
13811382

1382-
e.DescribeLoadBalancers(gomock.Eq(&elb.DescribeLoadBalancersInput{
1383-
LoadBalancerNames: aws.StringSlice([]string{"test-cluster-apiserver"}),
1383+
e.DescribeLoadBalancers(gomock.Any(), gomock.Eq(&elb.DescribeLoadBalancersInput{
1384+
LoadBalancerNames: []string{"test-cluster-apiserver"},
13841385
})).Return(&elb.DescribeLoadBalancersOutput{
1385-
LoadBalancerDescriptions: []*elb.LoadBalancerDescription{},
1386+
LoadBalancerDescriptions: []elbtypes.LoadBalancerDescription{},
13861387
}, nil)
13871388

1388-
e.CreateLoadBalancer(gomock.Eq(&elb.CreateLoadBalancerInput{
1389-
Listeners: []*elb.Listener{
1389+
e.CreateLoadBalancer(gomock.Any(), gomock.Eq(&elb.CreateLoadBalancerInput{
1390+
Listeners: []elbtypes.Listener{
13901391
{
1391-
InstancePort: aws.Int64(6443),
1392+
InstancePort: aws.Int32(6443),
13921393
InstanceProtocol: aws.String("TCP"),
1393-
LoadBalancerPort: aws.Int64(6443),
1394+
LoadBalancerPort: 6443,
13941395
Protocol: aws.String("TCP"),
13951396
},
13961397
},
13971398
LoadBalancerName: aws.String("test-cluster-apiserver"),
13981399
Scheme: aws.String("internet-facing"),
1399-
SecurityGroups: aws.StringSlice([]string{"sg-apiserver-lb"}),
1400-
Subnets: aws.StringSlice([]string{"subnet-2"}),
1401-
Tags: []*elb.Tag{
1400+
SecurityGroups: []string{"sg-apiserver-lb"},
1401+
Subnets: []string{"subnet-2"},
1402+
Tags: []elbtypes.Tag{
14021403
{
14031404
Key: aws.String("Name"),
14041405
Value: aws.String("test-cluster-apiserver"),
@@ -1416,14 +1417,14 @@ func mockedCallsForMissingEverything(m *mocks.MockEC2APIMockRecorder, e *mocks.M
14161417
DNSName: aws.String("unittest24.de"),
14171418
}, nil)
14181419

1419-
e.ConfigureHealthCheck(gomock.Eq(&elb.ConfigureHealthCheckInput{
1420+
e.ConfigureHealthCheck(gomock.Any(), gomock.Eq(&elb.ConfigureHealthCheckInput{
14201421
LoadBalancerName: aws.String("test-cluster-apiserver"),
1421-
HealthCheck: &elb.HealthCheck{
1422+
HealthCheck: &elbtypes.HealthCheck{
14221423
Target: aws.String("TCP:6443"),
1423-
Interval: aws.Int64(10),
1424-
Timeout: aws.Int64(5),
1425-
HealthyThreshold: aws.Int64(5),
1426-
UnhealthyThreshold: aws.Int64(3),
1424+
Interval: aws.Int32(10),
1425+
Timeout: aws.Int32(5),
1426+
HealthyThreshold: aws.Int32(5),
1427+
UnhealthyThreshold: aws.Int32(3),
14271428
},
14281429
})).Return(&elb.ConfigureHealthCheckOutput{}, nil)
14291430
}

controllers/awscluster_controller_unit_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
196196
g := NewWithT(t)
197197
runningCluster := func() {
198198
ec2Svc.EXPECT().ReconcileBastion().Return(nil)
199-
elbSvc.EXPECT().ReconcileLoadbalancers().Return(nil)
199+
elbSvc.EXPECT().ReconcileLoadbalancers(gomock.Any()).Return(nil)
200200
networkSvc.EXPECT().ReconcileNetwork().Return(nil)
201201
sgSvc.EXPECT().ReconcileSecurityGroups().Return(nil)
202202
}
@@ -252,7 +252,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
252252
g := NewWithT(t)
253253
runningCluster := func() {
254254
ec2Svc.EXPECT().ReconcileBastion().Return(nil)
255-
elbSvc.EXPECT().ReconcileLoadbalancers().Return(nil)
255+
elbSvc.EXPECT().ReconcileLoadbalancers(gomock.Any()).Return(nil)
256256
networkSvc.EXPECT().ReconcileNetwork().Return(nil)
257257
sgSvc.EXPECT().ReconcileSecurityGroups().Return(nil)
258258
}
@@ -352,7 +352,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
352352
networkSvc.EXPECT().ReconcileNetwork().Return(nil)
353353
sgSvc.EXPECT().ReconcileSecurityGroups().Return(nil)
354354
ec2Svc.EXPECT().ReconcileBastion().Return(nil)
355-
elbSvc.EXPECT().ReconcileLoadbalancers().Return(expectedErr)
355+
elbSvc.EXPECT().ReconcileLoadbalancers(gomock.Any()).Return(expectedErr)
356356
}
357357
csClient := setup(t, &awsCluster)
358358
defer teardown()
@@ -376,7 +376,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
376376
networkSvc.EXPECT().ReconcileNetwork().Return(nil)
377377
sgSvc.EXPECT().ReconcileSecurityGroups().Return(nil)
378378
ec2Svc.EXPECT().ReconcileBastion().Return(nil)
379-
elbSvc.EXPECT().ReconcileLoadbalancers().Return(nil)
379+
elbSvc.EXPECT().ReconcileLoadbalancers(gomock.Any()).Return(nil)
380380
}
381381
csClient := setup(t, &awsCluster)
382382
defer teardown()
@@ -399,7 +399,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
399399
t.Run("Reconcile success", func(t *testing.T) {
400400
deleteCluster := func() {
401401
ec2Svc.EXPECT().DeleteBastion().Return(nil)
402-
elbSvc.EXPECT().DeleteLoadbalancers().Return(nil)
402+
elbSvc.EXPECT().DeleteLoadbalancers(gomock.Any()).Return(nil)
403403
networkSvc.EXPECT().DeleteNetwork().Return(nil)
404404
sgSvc.EXPECT().DeleteSecurityGroups().Return(nil)
405405
}
@@ -429,7 +429,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
429429
g := NewWithT(t)
430430
deleteCluster := func() {
431431
t.Helper()
432-
elbSvc.EXPECT().DeleteLoadbalancers().Return(expectedErr)
432+
elbSvc.EXPECT().DeleteLoadbalancers(gomock.Any()).Return(expectedErr)
433433
ec2Svc.EXPECT().DeleteBastion().Return(nil)
434434
networkSvc.EXPECT().DeleteNetwork().Return(nil)
435435
sgSvc.EXPECT().DeleteSecurityGroups().Return(nil)
@@ -455,7 +455,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
455455
g := NewWithT(t)
456456
deleteCluster := func() {
457457
ec2Svc.EXPECT().DeleteBastion().Return(expectedErr)
458-
elbSvc.EXPECT().DeleteLoadbalancers().Return(nil)
458+
elbSvc.EXPECT().DeleteLoadbalancers(gomock.Any()).Return(nil)
459459
networkSvc.EXPECT().DeleteNetwork().Return(nil)
460460
sgSvc.EXPECT().DeleteSecurityGroups().Return(nil)
461461
}
@@ -480,7 +480,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
480480
g := NewWithT(t)
481481
deleteCluster := func() {
482482
ec2Svc.EXPECT().DeleteBastion().Return(nil)
483-
elbSvc.EXPECT().DeleteLoadbalancers().Return(nil)
483+
elbSvc.EXPECT().DeleteLoadbalancers(gomock.Any()).Return(nil)
484484
sgSvc.EXPECT().DeleteSecurityGroups().Return(expectedErr)
485485
networkSvc.EXPECT().DeleteNetwork().Return(nil)
486486
}
@@ -505,7 +505,7 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
505505
g := NewWithT(t)
506506
deleteCluster := func() {
507507
ec2Svc.EXPECT().DeleteBastion().Return(nil)
508-
elbSvc.EXPECT().DeleteLoadbalancers().Return(nil)
508+
elbSvc.EXPECT().DeleteLoadbalancers(gomock.Any()).Return(nil)
509509
sgSvc.EXPECT().DeleteSecurityGroups().Return(nil)
510510
networkSvc.EXPECT().DeleteNetwork().Return(expectedErr)
511511
}

controllers/awsmachine_controller.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type AWSMachineReconciler struct {
8787
Endpoints []scope.ServiceEndpoint
8888
WatchFilterValue string
8989
TagUnmanagedNetworkResources bool
90+
MaxWaitActiveUpdateDelete time.Duration
9091
}
9192

9293
const (
@@ -330,7 +331,7 @@ func (r *AWSMachineReconciler) reconcileDelete(ctx context.Context, machineScope
330331

331332
machineScope.Debug("EC2 instance found matching deleted AWSMachine", "instance-id", instance.ID)
332333

333-
if err := r.reconcileLBAttachment(machineScope, elbScope, instance); err != nil {
334+
if err := r.reconcileLBAttachment(ctx, machineScope, elbScope, instance); err != nil {
334335
// We are tolerating AccessDenied error, so this won't block for users with older version of IAM;
335336
// all the other errors are blocking.
336337
// Because we are reconciling all load balancers, attempt to treat the error as a list of errors.
@@ -641,7 +642,7 @@ func (r *AWSMachineReconciler) reconcileNormal(ctx context.Context, machineScope
641642
r.ensureStorageTags(ec2svc, instance, machineScope.AWSMachine, machineScope.AdditionalTags())
642643
}
643644

644-
if err := r.reconcileLBAttachment(machineScope, elbScope, instance); err != nil {
645+
if err := r.reconcileLBAttachment(ctx, machineScope, elbScope, instance); err != nil {
645646
// We are tolerating InstanceNotRunning error, so we don't report it as an error condition.
646647
// Because we are reconciling all load balancers, attempt to treat the error as a list of errors.
647648
if err := kerrors.FilterOut(err, elb.IsInstanceNotRunning); err != nil {
@@ -954,7 +955,7 @@ func (r *AWSMachineReconciler) deleteIgnitionBootstrapDataFromS3(ctx context.Con
954955

955956
// reconcileLBAttachment reconciles attachment to _all_ defined load balancers.
956957
// Callers are expected to filter out known-good errors out of the aggregate error list.
957-
func (r *AWSMachineReconciler) reconcileLBAttachment(machineScope *scope.MachineScope, elbScope scope.ELBScope, i *infrav1.Instance) error {
958+
func (r *AWSMachineReconciler) reconcileLBAttachment(ctx context.Context, machineScope *scope.MachineScope, elbScope scope.ELBScope, i *infrav1.Instance) error {
958959
if !machineScope.IsControlPlane() {
959960
return nil
960961
}
@@ -971,36 +972,36 @@ func (r *AWSMachineReconciler) reconcileLBAttachment(machineScope *scope.Machine
971972
if machineScope.AWSMachineIsDeleted() || machineScope.MachineIsDeleted() || !machineScope.InstanceIsRunning() {
972973
if lbSpec.LoadBalancerType == infrav1.LoadBalancerTypeClassic {
973974
machineScope.Debug("deregistering from classic load balancer")
974-
return r.deregisterInstanceFromClassicLB(machineScope, elbsvc, i)
975+
return r.deregisterInstanceFromClassicLB(ctx, machineScope, elbsvc, i)
975976
}
976977
machineScope.Debug("deregistering from v2 load balancer")
977-
errs = append(errs, r.deregisterInstanceFromV2LB(machineScope, elbsvc, i, lbSpec))
978+
errs = append(errs, r.deregisterInstanceFromV2LB(ctx, machineScope, elbsvc, i, lbSpec))
978979
continue
979980
}
980981

981-
if err := r.registerInstanceToLBs(machineScope, elbsvc, i, lbSpec); err != nil {
982+
if err := r.registerInstanceToLBs(ctx, machineScope, elbsvc, i, lbSpec); err != nil {
982983
errs = append(errs, errors.Wrapf(err, "could not register machine to load balancer"))
983984
}
984985
}
985986

986987
return kerrors.NewAggregate(errs)
987988
}
988989

989-
func (r *AWSMachineReconciler) registerInstanceToLBs(machineScope *scope.MachineScope, elbsvc services.ELBInterface, i *infrav1.Instance, lb *infrav1.AWSLoadBalancerSpec) error {
990+
func (r *AWSMachineReconciler) registerInstanceToLBs(ctx context.Context, machineScope *scope.MachineScope, elbsvc services.ELBInterface, i *infrav1.Instance, lb *infrav1.AWSLoadBalancerSpec) error {
990991
switch lb.LoadBalancerType {
991992
case infrav1.LoadBalancerTypeClassic, "":
992993
machineScope.Debug("registering to classic load balancer")
993-
return r.registerInstanceToClassicLB(machineScope, elbsvc, i)
994+
return r.registerInstanceToClassicLB(ctx, machineScope, elbsvc, i)
994995
case infrav1.LoadBalancerTypeELB, infrav1.LoadBalancerTypeALB, infrav1.LoadBalancerTypeNLB:
995996
machineScope.Debug("registering to v2 load balancer")
996-
return r.registerInstanceToV2LB(machineScope, elbsvc, i, lb)
997+
return r.registerInstanceToV2LB(ctx, machineScope, elbsvc, i, lb)
997998
}
998999

9991000
return errors.Errorf("unknown load balancer type %q", lb.LoadBalancerType)
10001001
}
10011002

1002-
func (r *AWSMachineReconciler) registerInstanceToClassicLB(machineScope *scope.MachineScope, elbsvc services.ELBInterface, i *infrav1.Instance) error {
1003-
registered, err := elbsvc.IsInstanceRegisteredWithAPIServerELB(i)
1003+
func (r *AWSMachineReconciler) registerInstanceToClassicLB(ctx context.Context, machineScope *scope.MachineScope, elbsvc services.ELBInterface, i *infrav1.Instance) error {
1004+
registered, err := elbsvc.IsInstanceRegisteredWithAPIServerELB(ctx, i)
10041005
if err != nil {
10051006
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedAttachControlPlaneELB",
10061007
"Failed to register control plane instance %q with classic load balancer: failed to determine registration status: %v", i.ID, err)
@@ -1011,7 +1012,7 @@ func (r *AWSMachineReconciler) registerInstanceToClassicLB(machineScope *scope.M
10111012
return nil
10121013
}
10131014

1014-
if err := elbsvc.RegisterInstanceWithAPIServerELB(i); err != nil {
1015+
if err := elbsvc.RegisterInstanceWithAPIServerELB(ctx, i); err != nil {
10151016
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedAttachControlPlaneELB",
10161017
"Failed to register control plane instance %q with classic load balancer: %v", i.ID, err)
10171018
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBAttachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
@@ -1023,8 +1024,8 @@ func (r *AWSMachineReconciler) registerInstanceToClassicLB(machineScope *scope.M
10231024
return nil
10241025
}
10251026

1026-
func (r *AWSMachineReconciler) registerInstanceToV2LB(machineScope *scope.MachineScope, elbsvc services.ELBInterface, instance *infrav1.Instance, lb *infrav1.AWSLoadBalancerSpec) error {
1027-
_, registered, err := elbsvc.IsInstanceRegisteredWithAPIServerLB(instance, lb)
1027+
func (r *AWSMachineReconciler) registerInstanceToV2LB(ctx context.Context, machineScope *scope.MachineScope, elbsvc services.ELBInterface, instance *infrav1.Instance, lb *infrav1.AWSLoadBalancerSpec) error {
1028+
_, registered, err := elbsvc.IsInstanceRegisteredWithAPIServerLB(ctx, instance, lb)
10281029
if err != nil {
10291030
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedAttachControlPlaneELB",
10301031
"Failed to register control plane instance %q with load balancer: failed to determine registration status: %v", instance.ID, err)
@@ -1043,7 +1044,7 @@ func (r *AWSMachineReconciler) registerInstanceToV2LB(machineScope *scope.Machin
10431044
return elb.NewInstanceNotRunning("instance is not running")
10441045
}
10451046

1046-
if err := elbsvc.RegisterInstanceWithAPIServerLB(instance, lb); err != nil {
1047+
if err := elbsvc.RegisterInstanceWithAPIServerLB(ctx, instance, lb); err != nil {
10471048
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedAttachControlPlaneELB",
10481049
"Failed to register control plane instance %q with load balancer: %v", instance.ID, err)
10491050
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBAttachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
@@ -1055,8 +1056,8 @@ func (r *AWSMachineReconciler) registerInstanceToV2LB(machineScope *scope.Machin
10551056
return nil
10561057
}
10571058

1058-
func (r *AWSMachineReconciler) deregisterInstanceFromClassicLB(machineScope *scope.MachineScope, elbsvc services.ELBInterface, instance *infrav1.Instance) error {
1059-
registered, err := elbsvc.IsInstanceRegisteredWithAPIServerELB(instance)
1059+
func (r *AWSMachineReconciler) deregisterInstanceFromClassicLB(ctx context.Context, machineScope *scope.MachineScope, elbsvc services.ELBInterface, instance *infrav1.Instance) error {
1060+
registered, err := elbsvc.IsInstanceRegisteredWithAPIServerELB(ctx, instance)
10601061
if err != nil {
10611062
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedDetachControlPlaneELB",
10621063
"Failed to deregister control plane instance %q from load balancer: failed to determine registration status: %v", instance.ID, err)
@@ -1067,7 +1068,7 @@ func (r *AWSMachineReconciler) deregisterInstanceFromClassicLB(machineScope *sco
10671068
return nil
10681069
}
10691070

1070-
if err := elbsvc.DeregisterInstanceFromAPIServerELB(instance); err != nil {
1071+
if err := elbsvc.DeregisterInstanceFromAPIServerELB(ctx, instance); err != nil {
10711072
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedDetachControlPlaneELB",
10721073
"Failed to deregister control plane instance %q from load balancer: %v", instance.ID, err)
10731074
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBDetachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
@@ -1079,8 +1080,8 @@ func (r *AWSMachineReconciler) deregisterInstanceFromClassicLB(machineScope *sco
10791080
return nil
10801081
}
10811082

1082-
func (r *AWSMachineReconciler) deregisterInstanceFromV2LB(machineScope *scope.MachineScope, elbsvc services.ELBInterface, i *infrav1.Instance, lb *infrav1.AWSLoadBalancerSpec) error {
1083-
targetGroupARNs, registered, err := elbsvc.IsInstanceRegisteredWithAPIServerLB(i, lb)
1083+
func (r *AWSMachineReconciler) deregisterInstanceFromV2LB(ctx context.Context, machineScope *scope.MachineScope, elbsvc services.ELBInterface, i *infrav1.Instance, lb *infrav1.AWSLoadBalancerSpec) error {
1084+
targetGroupARNs, registered, err := elbsvc.IsInstanceRegisteredWithAPIServerLB(ctx, i, lb)
10841085
if err != nil {
10851086
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedDetachControlPlaneELB",
10861087
"Failed to deregister control plane instance %q from load balancer: failed to determine registration status: %v", i.ID, err)
@@ -1092,7 +1093,7 @@ func (r *AWSMachineReconciler) deregisterInstanceFromV2LB(machineScope *scope.Ma
10921093
}
10931094

10941095
for _, targetGroupArn := range targetGroupARNs {
1095-
if err := elbsvc.DeregisterInstanceFromAPIServerLB(targetGroupArn, i); err != nil {
1096+
if err := elbsvc.DeregisterInstanceFromAPIServerLB(ctx, targetGroupArn, i); err != nil {
10961097
r.Recorder.Eventf(machineScope.AWSMachine, corev1.EventTypeWarning, "FailedDetachControlPlaneELB",
10971098
"Failed to deregister control plane instance %q from load balancer: %v", i.ID, err)
10981099
conditions.MarkFalse(machineScope.AWSMachine, infrav1.ELBAttachedCondition, infrav1.ELBDetachFailedReason, clusterv1.ConditionSeverityError, "%s", err.Error())
@@ -1234,6 +1235,7 @@ func (r *AWSMachineReconciler) getInfraCluster(ctx context.Context, log *logger.
12341235
AWSCluster: awsCluster,
12351236
ControllerName: "awsmachine",
12361237
TagUnmanagedNetworkResources: r.TagUnmanagedNetworkResources,
1238+
MaxWaitActiveUpdateDelete: r.MaxWaitActiveUpdateDelete,
12371239
})
12381240
if err != nil {
12391241
return nil, err

0 commit comments

Comments
 (0)