@@ -81,6 +81,8 @@ const (
8181 mapiNamespace string = "openshift-machine-api"
8282 capiInfraCommonFinalizerSuffix string = ".cluster.x-k8s.io"
8383
84+ requeueInfraProgress = 1 * time .Second
85+
8486 messageSuccessfullySynchronizedCAPItoMAPI = "Successfully synchronized CAPI Machine to MAPI"
8587 messageSuccessfullySynchronizedMAPItoCAPI = "Successfully synchronized MAPI Machine to CAPI"
8688 progressingToSynchronizeMAPItoCAPI = "Progressing to synchronize MAPI Machine to CAPI"
@@ -134,7 +136,7 @@ type MachineSyncReconciler struct {
134136 MAPINamespace string
135137}
136138
137- // SetupWithManager sets the CoreClusterReconciler controller up with the given manager.
139+ // SetupWithManager sets the MachineSyncReconciler controller up with the given manager.
138140func (r * MachineSyncReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
139141 infraMachine , _ , err := controllers .InitInfraMachineAndInfraClusterFromProvider (r .Platform )
140142 if err != nil {
@@ -161,7 +163,7 @@ func (r *MachineSyncReconciler) SetupWithManager(mgr ctrl.Manager) error {
161163 ).
162164 Watches (
163165 infraMachine ,
164- handler .EnqueueRequestsFromMapFunc (util .RewriteNamespace (r .MAPINamespace )),
166+ handler .EnqueueRequestsFromMapFunc (util .ResolveCAPIMachineFromInfraMachine (r .MAPINamespace )),
165167 builder .WithPredicates (util .FilterNamespace (r .CAPINamespace )),
166168 ).
167169 Complete (r ); err != nil {
@@ -182,8 +184,8 @@ func (r *MachineSyncReconciler) SetupWithManager(mgr ctrl.Manager) error {
182184func (r * MachineSyncReconciler ) Reconcile (ctx context.Context , req reconcile.Request ) (ctrl.Result , error ) {
183185 logger := log .FromContext (ctx , "namespace" , req .Namespace , "name" , req .Name )
184186
185- logger .V ( 1 ). Info ("Reconciling machine" )
186- defer logger .V ( 1 ). Info ("Finished reconciling machine" )
187+ logger .Info ("Reconciling machine" )
188+ defer logger .Info ("Finished reconciling machine" )
187189
188190 var mapiMachineNotFound , capiMachineNotFound bool
189191
@@ -540,13 +542,13 @@ func (r *MachineSyncReconciler) reconcileMAPIMachinetoCAPIMachine(ctx context.Co
540542 BlockOwnerDeletion : ptr .To (true ),
541543 }})
542544
543- result , syncronizationIsProgressing , err := r .createOrUpdateCAPIInfraMachine (ctx , mapiMachine , infraMachine , newCAPIInfraMachine )
545+ result , synchronizationIsProgressing , err := r .createOrUpdateCAPIInfraMachine (ctx , mapiMachine , infraMachine , newCAPIInfraMachine )
544546 if err != nil {
545547 return result , fmt .Errorf ("unable to ensure Cluster API infra machine: %w" , err )
546548 }
547549
548- if syncronizationIsProgressing {
549- return ctrl.Result {RequeueAfter : time . Second * 1 }, r .applySynchronizedConditionWithPatch (ctx , mapiMachine , corev1 .ConditionUnknown ,
550+ if synchronizationIsProgressing {
551+ return ctrl.Result {RequeueAfter : requeueInfraProgress }, r .applySynchronizedConditionWithPatch (ctx , mapiMachine , corev1 .ConditionUnknown ,
550552 reasonProgressingToCreateCAPIInfraMachine , progressingToSynchronizeMAPItoCAPI , nil )
551553 }
552554
@@ -1011,7 +1013,9 @@ func (r *MachineSyncReconciler) fetchCAPIInfraResources(ctx context.Context, cap
10111013}
10121014
10131015//nolint:funlen,gocognit,cyclop
1014- func (r * MachineSyncReconciler ) reconcileMAPItoCAPIMachineDeletion (ctx context.Context , mapiMachine * machinev1beta1.Machine , capiMachine * clusterv1.Machine , infraMachine client.Object ) (bool , error ) {
1016+ func (r * MachineSyncReconciler ) reconcileMAPItoCAPIMachineDeletion (ctx context.Context , mapiMachine * machinev1beta1.Machine , capiMachine * clusterv1.Machine , infraMachine client.Object ) (shouldReqeue bool , err error ) {
1017+ logger := log .FromContext (ctx )
1018+
10151019 if mapiMachine .DeletionTimestamp .IsZero () {
10161020 if capiMachine == nil || capiMachine .DeletionTimestamp .IsZero () {
10171021 // Neither MAPI authoritative machine nor its CAPI non-authoritative machine mirror
@@ -1029,8 +1033,6 @@ func (r *MachineSyncReconciler) reconcileMAPItoCAPIMachineDeletion(ctx context.C
10291033 return true , nil
10301034 }
10311035
1032- logger := log .FromContext (ctx )
1033-
10341036 if capiMachine == nil && util .IsNilObject (infraMachine ) {
10351037 logger .Info ("Cluster API machine and infra machine do not exist, removing corresponding Machine API machine sync finalizer" )
10361038 // We don't have a capi machine or infra resouorces to clean up we can
@@ -1228,9 +1230,7 @@ func (r *MachineSyncReconciler) reconcileCAPItoMAPIMachineDeletion(ctx context.C
12281230
12291231// ensureSyncFinalizer ensures the sync finalizer is present across the mapi
12301232// machine, capi machine and capi infra machine.
1231- func (r * MachineSyncReconciler ) ensureSyncFinalizer (ctx context.Context , mapiMachine * machinev1beta1.Machine , capiMachine * clusterv1.Machine , infraMachine client.Object ) (bool , error ) {
1232- var shouldRequeue bool
1233-
1233+ func (r * MachineSyncReconciler ) ensureSyncFinalizer (ctx context.Context , mapiMachine * machinev1beta1.Machine , capiMachine * clusterv1.Machine , infraMachine client.Object ) (shouldRequeue bool , err error ) {
12341234 var errors []error
12351235
12361236 if mapiMachine != nil {
0 commit comments