@@ -61,6 +61,7 @@ type AWSMachinePoolReconciler struct {
6161 WatchFilterValue string
6262 asgServiceFactory func (cloud.ClusterScoper ) services.ASGInterface
6363 ec2ServiceFactory func (scope.EC2Scope ) services.EC2Interface
64+ reconcileServiceFactory func (scope.EC2Scope ) services.MachinePoolReconcileInterface
6465 TagUnmanagedNetworkResources bool
6566}
6667
@@ -79,6 +80,14 @@ func (r *AWSMachinePoolReconciler) getEC2Service(scope scope.EC2Scope) services.
7980 return ec2 .NewService (scope )
8081}
8182
83+ func (r * AWSMachinePoolReconciler ) getReconcileService (scope scope.EC2Scope ) services.MachinePoolReconcileInterface {
84+ if r .reconcileServiceFactory != nil {
85+ return r .reconcileServiceFactory (scope )
86+ }
87+
88+ return ec2 .NewService (scope )
89+ }
90+
8291// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsmachinepools,verbs=get;list;watch;update;patch;delete
8392// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsmachinepools/status,verbs=get;update;patch
8493// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machinepools;machinepools/status,verbs=get;list;watch;patch
@@ -227,6 +236,7 @@ func (r *AWSMachinePoolReconciler) reconcileNormal(ctx context.Context, machineP
227236
228237 ec2Svc := r .getEC2Service (ec2Scope )
229238 asgsvc := r .getASGService (clusterScope )
239+ reconSvc := r .getReconcileService (ec2Scope )
230240
231241 // Find existing ASG
232242 asg , err := r .findASG (machinePoolScope , asgsvc )
@@ -269,7 +279,7 @@ func (r *AWSMachinePoolReconciler) reconcileNormal(ctx context.Context, machineP
269279 machinePoolScope .Info ("starting instance refresh" , "number of instances" , machinePoolScope .MachinePool .Spec .Replicas )
270280 return asgsvc .StartASGInstanceRefresh (machinePoolScope )
271281 }
272- if err := ec2Svc .ReconcileLaunchTemplate (machinePoolScope , canUpdateLaunchTemplate , runPostLaunchTemplateUpdateOperation ); err != nil {
282+ if err := reconSvc .ReconcileLaunchTemplate (machinePoolScope , ec2Svc , canUpdateLaunchTemplate , runPostLaunchTemplateUpdateOperation ); err != nil {
273283 r .Recorder .Eventf (machinePoolScope .AWSMachinePool , corev1 .EventTypeWarning , "FailedLaunchTemplateReconcile" , "Failed to reconcile launch template: %v" , err )
274284 machinePoolScope .Error (err , "failed to reconcile launch template" )
275285 return err
@@ -317,7 +327,7 @@ func (r *AWSMachinePoolReconciler) reconcileNormal(ctx context.Context, machineP
317327 ResourceService : asgsvc ,
318328 },
319329 }
320- err = ec2Svc .ReconcileTags (machinePoolScope , resourceServiceToUpdate )
330+ err = reconSvc .ReconcileTags (machinePoolScope , resourceServiceToUpdate )
321331 if err != nil {
322332 return errors .Wrap (err , "error updating tags" )
323333 }
@@ -378,7 +388,7 @@ func (r *AWSMachinePoolReconciler) reconcileDelete(machinePoolScope *scope.Machi
378388 }
379389
380390 launchTemplateID := machinePoolScope .AWSMachinePool .Status .LaunchTemplateID
381- launchTemplate , _ , err := ec2Svc .GetLaunchTemplate (machinePoolScope .LaunchTemplateName ())
391+ launchTemplate , _ , _ , err := ec2Svc .GetLaunchTemplate (machinePoolScope .LaunchTemplateName ())
382392 if err != nil {
383393 return err
384394 }
@@ -422,7 +432,7 @@ func (r *AWSMachinePoolReconciler) updatePool(machinePoolScope *scope.MachinePoo
422432
423433 asgDiff := diffASG (machinePoolScope , existingASG )
424434 if asgDiff != "" {
425- machinePoolScope .Debug ("asg diff detected" , "diff " , subnetDiff )
435+ machinePoolScope .Debug ("asg diff detected" , "asgDiff" , asgDiff , "subnetDiff " , subnetDiff )
426436 }
427437 if asgDiff != "" || subnetDiff != "" {
428438 machinePoolScope .Info ("updating AutoScalingGroup" )
0 commit comments