project-codeflare / instascale

On-demand Kubernetes/OpenShift cluster scaling and aggregated resource provisioning
Apache License 2.0
10 stars 20 forks source link

Refactor Machine Type detection logic out of the reconcile function. #172

Open VanillaSpoon opened 1 year ago

VanillaSpoon commented 1 year ago

WHY

The current implementation of Instascale includes logic within the Reconcile function to check and set the machine type and verify if Hypershift is enabled. This logic is placed in the reconciliation loop because the client is not able to perform calls to the Kubernetes API until after the controller's SetupWithManager method has completed. As a result, fetching the ocmClusterId and checking if Hypershift is enabled cannot be done during setup.

The machineCheck is a crucial part of the controller setup, as it dictates the behaviour of the reconciliation process by determining whether we are working with a MachinePool, or NodePool. Performing this operation in the reconcile function is not optimal.

DONE

The machine type and Hypershift checks should be refactored out of the Reconcile loop to improve the controller's efficiency and code maintainability.