The existing machine reconciliation code leveraged 3 different data structures (TinkerbellMachineReconciler, machineReconcileContext and baseMachineReconcileContext) and 2 interfaces (ReconcileContext and BaseMachineReconcileContext).
The machineReconcileContext extends the baseMachineReconcileContext but the relationship is misappropriated and superfluous.
The ReconcileContext and the BaseMachineReconcileContext have no discernible purpose.
Changes
Delete the ReconcileContext and BaseMachineReconcileContext interfaces.
Combine the baseMachineReconcileContext and machineReconcileContext into a single data structure, machineReconcileScope.
Move machineReconcileScope construction logic to the TinkerbellMachineReconciler.Reconcile() call keeping the construction in a single place.
Motivation
Simpler code is easier to maintain.
Updating to newer versions of Cluster API are easier when we understand the code better.
What's next?
There's too close a relationship between the construction logic and delete reconciliation.
Rework package structure so objects can be better tested (probably through the use of internal packages).
Evaluating other logic to check for bugs. On performing this refactor there were some interesting smells that could contribute to recent reports of objects not reconciling.
Summary
The existing machine reconciliation code leveraged 3 different data structures (
TinkerbellMachineReconciler
,machineReconcileContext
andbaseMachineReconcileContext
) and 2 interfaces (ReconcileContext
andBaseMachineReconcileContext
).The
machineReconcileContext
extends thebaseMachineReconcileContext
but the relationship is misappropriated and superfluous.The
ReconcileContext
and theBaseMachineReconcileContext
have no discernible purpose.Changes
ReconcileContext
andBaseMachineReconcileContext
interfaces.baseMachineReconcileContext
andmachineReconcileContext
into a single data structure,machineReconcileScope
.machineReconcileScope
construction logic to theTinkerbellMachineReconciler.Reconcile()
call keeping the construction in a single place.Motivation
What's next?