@@ -172,18 +172,13 @@ func (r *ControlPlaneMachineSetGeneratorReconciler) reconcile(ctx context.Contex
172172 return reconcile.Result {}, nil
173173 }
174174
175- machineSets , err := r .getMachineSets (ctx )
176- if err != nil {
177- return reconcile.Result {}, fmt .Errorf ("failed to get machinesets: %w" , err )
178- }
179-
180175 infrastructure , err := util .GetInfrastructure (ctx , r .Client )
181176 if err != nil {
182177 return reconcile.Result {}, fmt .Errorf ("failed to get infrastructure object: %w" , err )
183178 }
184179
185180 // generate an up to date ControlPlaneMachineSet based on the current cluster state.
186- generatedCPMS , err := r .generateControlPlaneMachineSet (logger , infrastructure , machines , machineSets )
181+ generatedCPMS , err := r .generateControlPlaneMachineSet (logger , infrastructure , machines )
187182 if errors .Is (err , errUnsupportedPlatform ) {
188183 // Do not requeue if the platform is not supported.
189184 // Nothing to do in this case.
@@ -219,7 +214,7 @@ func (r *ControlPlaneMachineSetGeneratorReconciler) reconcile(ctx context.Contex
219214// generateControlPlaneMachineSet generates a control plane machine set based on the current cluster state.
220215//
221216//nolint:cyclop
222- func (r * ControlPlaneMachineSetGeneratorReconciler ) generateControlPlaneMachineSet (logger logr.Logger , infrastructure * configv1.Infrastructure , machines []machinev1beta1.Machine , machineSets []machinev1beta1. MachineSet ) (* machinev1.ControlPlaneMachineSet , error ) {
217+ func (r * ControlPlaneMachineSetGeneratorReconciler ) generateControlPlaneMachineSet (logger logr.Logger , infrastructure * configv1.Infrastructure , machines []machinev1beta1.Machine ) (* machinev1.ControlPlaneMachineSet , error ) {
223218 var (
224219 cpmsSpecApplyConfig machinev1builder.ControlPlaneMachineSetSpecApplyConfiguration
225220 err error
@@ -229,32 +224,32 @@ func (r *ControlPlaneMachineSetGeneratorReconciler) generateControlPlaneMachineS
229224
230225 switch platformType {
231226 case configv1 .AWSPlatformType :
232- cpmsSpecApplyConfig , err = generateControlPlaneMachineSetAWSSpec (logger , machines , machineSets )
227+ cpmsSpecApplyConfig , err = generateControlPlaneMachineSetAWSSpec (logger , machines )
233228 if err != nil {
234229 return nil , fmt .Errorf ("unable to generate control plane machine set spec: %w" , err )
235230 }
236231 case configv1 .AzurePlatformType :
237- cpmsSpecApplyConfig , err = generateControlPlaneMachineSetAzureSpec (logger , machines , machineSets )
232+ cpmsSpecApplyConfig , err = generateControlPlaneMachineSetAzureSpec (logger , machines )
238233 if err != nil {
239234 return nil , fmt .Errorf ("unable to generate control plane machine set spec: %w" , err )
240235 }
241236 case configv1 .GCPPlatformType :
242- cpmsSpecApplyConfig , err = generateControlPlaneMachineSetGCPSpec (logger , machines , machineSets )
237+ cpmsSpecApplyConfig , err = generateControlPlaneMachineSetGCPSpec (logger , machines )
243238 if err != nil {
244239 return nil , fmt .Errorf ("unable to generate control plane machine set spec: %w" , err )
245240 }
246241 case configv1 .NutanixPlatformType :
247- cpmsSpecApplyConfig , err = generateControlPlaneMachineSetNutanixSpec (logger , machines , machineSets , infrastructure )
242+ cpmsSpecApplyConfig , err = generateControlPlaneMachineSetNutanixSpec (logger , machines , infrastructure )
248243 if err != nil {
249244 return nil , fmt .Errorf ("unable to generate control plane machine set spec: %w" , err )
250245 }
251246 case configv1 .OpenStackPlatformType :
252- cpmsSpecApplyConfig , err = generateControlPlaneMachineSetOpenStackSpec (logger , machines , machineSets )
247+ cpmsSpecApplyConfig , err = generateControlPlaneMachineSetOpenStackSpec (logger , machines )
253248 if err != nil {
254249 return nil , fmt .Errorf ("unable to generate control plane machine set spec: %w" , err )
255250 }
256251 case configv1 .VSpherePlatformType :
257- cpmsSpecApplyConfig , err = generateControlPlaneMachineSetVSphereSpec (logger , machines , machineSets , infrastructure )
252+ cpmsSpecApplyConfig , err = generateControlPlaneMachineSetVSphereSpec (logger , machines , infrastructure )
258253 if err != nil {
259254 return nil , fmt .Errorf ("unable to generate control plane machine set spec: %w" , err )
260255 }
@@ -344,16 +339,6 @@ func (r *ControlPlaneMachineSetGeneratorReconciler) getControlPlaneMachines(ctx
344339 return sortMachinesByCreationTimeDescending (machines ), nil
345340}
346341
347- // getMachineSets returns a sorted slice of MachineSets.
348- func (r * ControlPlaneMachineSetGeneratorReconciler ) getMachineSets (ctx context.Context ) ([]machinev1beta1.MachineSet , error ) {
349- machineSets := & machinev1beta1.MachineSetList {}
350- if err := r .List (ctx , machineSets , client .InNamespace (r .Namespace )); err != nil {
351- return nil , fmt .Errorf ("unable to list control plane machines: %w" , err )
352- }
353-
354- return sortMachineSetsByCreationTimeAscending (machineSets .Items ), nil
355- }
356-
357342// isSupportedControlPlaneMachinesNumber checks if the number of control plane machines in the cluster is supported by the ControlPlaneMachineSet.
358343func (r * ControlPlaneMachineSetGeneratorReconciler ) isSupportedControlPlaneMachinesNumber (logger logr.Logger , machines []machinev1beta1.Machine ) bool {
359344 // Single Control Plane Machine Clusters are not supported by control plane machine set.
0 commit comments