Skip to content

Commit

Permalink
final clean-up
Browse files Browse the repository at this point in the history
With removal of the legacy updateStatus(), updateStatusNew() can be renamed
to the original name.

With removal of the legacy updateStatus() infrastructure getMcp() is left
with no callers and can be removed.

With removal of getMcp() the last remaining caller of
getMcpNameIfMcpExists() is removed so this function can finally be removed
too.  This concludes a refactor started in commit 3adfbd5.

Signed-off-by: Pavel Mores <pmores@redhat.com>
  • Loading branch information
pmores committed Jun 28, 2023
1 parent fd25515 commit 3a7ac8d
Showing 1 changed file with 3 additions and 36 deletions.
39 changes: 3 additions & 36 deletions controllers/openshift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,23 +650,6 @@ func (r *KataConfigOpenShiftReconciler) checkNodeEligibility() error {
return nil
}

func (r *KataConfigOpenShiftReconciler) getMcpNameIfMcpExists() (string, error) {
r.Log.Info("Getting MachineConfigPool Name")

kataOC, err := r.kataOcExists()
if kataOC && err == nil {
r.Log.Info("kata-oc MachineConfigPool exists")
return "kata-oc", nil
}
isConvergedCluster, err := r.checkConvergedCluster()
if err == nil && isConvergedCluster {
r.Log.Info("Converged Cluster. Not creating kata-oc MCP")
return "master", nil
}
r.Log.Info("No valid MCP found")
return "", err
}

func (r *KataConfigOpenShiftReconciler) getMcpName() (string, error) {
isConvergedCluster, err := r.checkConvergedCluster()
if err != nil {
Expand Down Expand Up @@ -937,7 +920,7 @@ func (r *KataConfigOpenShiftReconciler) processKataConfigDeleteRequest() (ctrl.R
r.kataConfig.Status.WaitingForMcoToStart = false
}

err = r.updateStatusNew()
err = r.updateStatus()
if err != nil {
r.Log.Info("Error updating KataConfig.status", "err", err)
}
Expand Down Expand Up @@ -1142,7 +1125,7 @@ func (r *KataConfigOpenShiftReconciler) processKataConfigInstallRequest() (ctrl.
r.kataConfig.Status.WaitingForMcoToStart = false
}

err = r.updateStatusNew()
err = r.updateStatus()
if err != nil {
r.Log.Info("Error updating KataConfig.status", "err", err)
}
Expand Down Expand Up @@ -1537,22 +1520,6 @@ func (r *KataConfigOpenShiftReconciler) SetupWithManager(mgr ctrl.Manager) error
Complete(r)
}

func (r *KataConfigOpenShiftReconciler) getMcp() (*mcfgv1.MachineConfigPool, error) {
machinePool, err := r.getMcpNameIfMcpExists()
if err != nil {
return nil, err
}

foundMcp := &mcfgv1.MachineConfigPool{}
err = r.Client.Get(context.TODO(), types.NamespacedName{Name: machinePool}, foundMcp)
if err != nil {
r.Log.Error(err, "Getting MachineConfigPool failed ", "machinePool", machinePool)
return nil, err
}

return foundMcp, nil
}

func (r *KataConfigOpenShiftReconciler) getNodes() (error, *corev1.NodeList) {
nodes := &corev1.NodeList{}
labelSelector := labels.SelectorFromSet(map[string]string{"node-role.kubernetes.io/worker": ""})
Expand Down Expand Up @@ -1813,7 +1780,7 @@ func (r *KataConfigOpenShiftReconciler) processDoneNode(node *corev1.Node) error

// If multiple errors occur during execution of this function the last one
// will be returned.
func (r *KataConfigOpenShiftReconciler) updateStatusNew() error {
func (r *KataConfigOpenShiftReconciler) updateStatus() error {

if r.kataConfig.Status.UnInstallationStatus.InProgress.IsInProgress != corev1.ConditionTrue &&
r.kataConfig.Status.InstallationStatus.IsInProgress != corev1.ConditionTrue {
Expand Down

0 comments on commit 3a7ac8d

Please sign in to comment.