@@ -87,6 +87,7 @@ type AWSMachineReconciler struct {
87
87
Endpoints []scope.ServiceEndpoint
88
88
WatchFilterValue string
89
89
TagUnmanagedNetworkResources bool
90
+ MaxWaitActiveUpdateDelete time.Duration
90
91
}
91
92
92
93
const (
@@ -330,7 +331,7 @@ func (r *AWSMachineReconciler) reconcileDelete(ctx context.Context, machineScope
330
331
331
332
machineScope .Debug ("EC2 instance found matching deleted AWSMachine" , "instance-id" , instance .ID )
332
333
333
- if err := r .reconcileLBAttachment (machineScope , elbScope , instance ); err != nil {
334
+ if err := r .reconcileLBAttachment (ctx , machineScope , elbScope , instance ); err != nil {
334
335
// We are tolerating AccessDenied error, so this won't block for users with older version of IAM;
335
336
// all the other errors are blocking.
336
337
// 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
641
642
r .ensureStorageTags (ec2svc , instance , machineScope .AWSMachine , machineScope .AdditionalTags ())
642
643
}
643
644
644
- if err := r .reconcileLBAttachment (machineScope , elbScope , instance ); err != nil {
645
+ if err := r .reconcileLBAttachment (ctx , machineScope , elbScope , instance ); err != nil {
645
646
// We are tolerating InstanceNotRunning error, so we don't report it as an error condition.
646
647
// Because we are reconciling all load balancers, attempt to treat the error as a list of errors.
647
648
if err := kerrors .FilterOut (err , elb .IsInstanceNotRunning ); err != nil {
@@ -954,7 +955,7 @@ func (r *AWSMachineReconciler) deleteIgnitionBootstrapDataFromS3(ctx context.Con
954
955
955
956
// reconcileLBAttachment reconciles attachment to _all_ defined load balancers.
956
957
// 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 {
958
959
if ! machineScope .IsControlPlane () {
959
960
return nil
960
961
}
@@ -971,36 +972,36 @@ func (r *AWSMachineReconciler) reconcileLBAttachment(machineScope *scope.Machine
971
972
if machineScope .AWSMachineIsDeleted () || machineScope .MachineIsDeleted () || ! machineScope .InstanceIsRunning () {
972
973
if lbSpec .LoadBalancerType == infrav1 .LoadBalancerTypeClassic {
973
974
machineScope .Debug ("deregistering from classic load balancer" )
974
- return r .deregisterInstanceFromClassicLB (machineScope , elbsvc , i )
975
+ return r .deregisterInstanceFromClassicLB (ctx , machineScope , elbsvc , i )
975
976
}
976
977
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 ))
978
979
continue
979
980
}
980
981
981
- if err := r .registerInstanceToLBs (machineScope , elbsvc , i , lbSpec ); err != nil {
982
+ if err := r .registerInstanceToLBs (ctx , machineScope , elbsvc , i , lbSpec ); err != nil {
982
983
errs = append (errs , errors .Wrapf (err , "could not register machine to load balancer" ))
983
984
}
984
985
}
985
986
986
987
return kerrors .NewAggregate (errs )
987
988
}
988
989
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 {
990
991
switch lb .LoadBalancerType {
991
992
case infrav1 .LoadBalancerTypeClassic , "" :
992
993
machineScope .Debug ("registering to classic load balancer" )
993
- return r .registerInstanceToClassicLB (machineScope , elbsvc , i )
994
+ return r .registerInstanceToClassicLB (ctx , machineScope , elbsvc , i )
994
995
case infrav1 .LoadBalancerTypeELB , infrav1 .LoadBalancerTypeALB , infrav1 .LoadBalancerTypeNLB :
995
996
machineScope .Debug ("registering to v2 load balancer" )
996
- return r .registerInstanceToV2LB (machineScope , elbsvc , i , lb )
997
+ return r .registerInstanceToV2LB (ctx , machineScope , elbsvc , i , lb )
997
998
}
998
999
999
1000
return errors .Errorf ("unknown load balancer type %q" , lb .LoadBalancerType )
1000
1001
}
1001
1002
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 )
1004
1005
if err != nil {
1005
1006
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedAttachControlPlaneELB" ,
1006
1007
"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
1011
1012
return nil
1012
1013
}
1013
1014
1014
- if err := elbsvc .RegisterInstanceWithAPIServerELB (i ); err != nil {
1015
+ if err := elbsvc .RegisterInstanceWithAPIServerELB (ctx , i ); err != nil {
1015
1016
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedAttachControlPlaneELB" ,
1016
1017
"Failed to register control plane instance %q with classic load balancer: %v" , i .ID , err )
1017
1018
conditions .MarkFalse (machineScope .AWSMachine , infrav1 .ELBAttachedCondition , infrav1 .ELBAttachFailedReason , clusterv1 .ConditionSeverityError , "%s" , err .Error ())
@@ -1023,8 +1024,8 @@ func (r *AWSMachineReconciler) registerInstanceToClassicLB(machineScope *scope.M
1023
1024
return nil
1024
1025
}
1025
1026
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 )
1028
1029
if err != nil {
1029
1030
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedAttachControlPlaneELB" ,
1030
1031
"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
1043
1044
return elb .NewInstanceNotRunning ("instance is not running" )
1044
1045
}
1045
1046
1046
- if err := elbsvc .RegisterInstanceWithAPIServerLB (instance , lb ); err != nil {
1047
+ if err := elbsvc .RegisterInstanceWithAPIServerLB (ctx , instance , lb ); err != nil {
1047
1048
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedAttachControlPlaneELB" ,
1048
1049
"Failed to register control plane instance %q with load balancer: %v" , instance .ID , err )
1049
1050
conditions .MarkFalse (machineScope .AWSMachine , infrav1 .ELBAttachedCondition , infrav1 .ELBAttachFailedReason , clusterv1 .ConditionSeverityError , "%s" , err .Error ())
@@ -1055,8 +1056,8 @@ func (r *AWSMachineReconciler) registerInstanceToV2LB(machineScope *scope.Machin
1055
1056
return nil
1056
1057
}
1057
1058
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 )
1060
1061
if err != nil {
1061
1062
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedDetachControlPlaneELB" ,
1062
1063
"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
1067
1068
return nil
1068
1069
}
1069
1070
1070
- if err := elbsvc .DeregisterInstanceFromAPIServerELB (instance ); err != nil {
1071
+ if err := elbsvc .DeregisterInstanceFromAPIServerELB (ctx , instance ); err != nil {
1071
1072
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedDetachControlPlaneELB" ,
1072
1073
"Failed to deregister control plane instance %q from load balancer: %v" , instance .ID , err )
1073
1074
conditions .MarkFalse (machineScope .AWSMachine , infrav1 .ELBAttachedCondition , infrav1 .ELBDetachFailedReason , clusterv1 .ConditionSeverityError , "%s" , err .Error ())
@@ -1079,8 +1080,8 @@ func (r *AWSMachineReconciler) deregisterInstanceFromClassicLB(machineScope *sco
1079
1080
return nil
1080
1081
}
1081
1082
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 )
1084
1085
if err != nil {
1085
1086
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedDetachControlPlaneELB" ,
1086
1087
"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
1092
1093
}
1093
1094
1094
1095
for _ , targetGroupArn := range targetGroupARNs {
1095
- if err := elbsvc .DeregisterInstanceFromAPIServerLB (targetGroupArn , i ); err != nil {
1096
+ if err := elbsvc .DeregisterInstanceFromAPIServerLB (ctx , targetGroupArn , i ); err != nil {
1096
1097
r .Recorder .Eventf (machineScope .AWSMachine , corev1 .EventTypeWarning , "FailedDetachControlPlaneELB" ,
1097
1098
"Failed to deregister control plane instance %q from load balancer: %v" , i .ID , err )
1098
1099
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.
1234
1235
AWSCluster : awsCluster ,
1235
1236
ControllerName : "awsmachine" ,
1236
1237
TagUnmanagedNetworkResources : r .TagUnmanagedNetworkResources ,
1238
+ MaxWaitActiveUpdateDelete : r .MaxWaitActiveUpdateDelete ,
1237
1239
})
1238
1240
if err != nil {
1239
1241
return nil , err
0 commit comments