Skip to content

Commit

Permalink
report ROSAMachinePool reconcilation erros in condition
Browse files Browse the repository at this point in the history
- fixed machinepool triggering an upgrade when upgrading controlPlane
  • Loading branch information
muraee committed Mar 12, 2024
1 parent d5f6762 commit d60bc63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions exp/api/v1beta2/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ const (
RosaMachinePoolReadyCondition clusterv1.ConditionType = "RosaMchinePoolReady"
// RosaMachinePoolUpgradingCondition condition reports whether ROSAMachinePool is upgrading or not.
RosaMachinePoolUpgradingCondition clusterv1.ConditionType = "RosaMchinePoolUpgrading"

// WaitingForRosaControlPlaneReason used when the machine pool is waiting for
// ROSA control plane infrastructure to be ready before proceeding.
WaitingForRosaControlPlaneReason = "WaitingForRosaControlPlane"

// RosaMachinePoolReconciliationFailedReason used to report failures while reconciling ROSAMachinePool.
RosaMachinePoolReconciliationFailedReason = "ReconciliationFailed"
)
16 changes: 11 additions & 5 deletions exp/controllers/rosamachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ func (r *ROSAMachinePoolReconciler) reconcileNormal(ctx context.Context,

nodePool, err = ocmClient.CreateNodePool(machinePoolScope.ControlPlane.Status.ID, nodePoolSpec)
if err != nil {
conditions.MarkFalse(rosaMachinePool,
expinfrav1.RosaMachinePoolReadyCondition,
expinfrav1.RosaMachinePoolReconciliationFailedReason,
clusterv1.ConditionSeverityError,
"failed to create ROSAMachinePool: %s", err.Error())
return ctrl.Result{}, fmt.Errorf("failed to create nodepool: %w", err)
}

Expand Down Expand Up @@ -308,11 +313,7 @@ func (r *ROSAMachinePoolReconciler) reconcileDelete(

func (r *ROSAMachinePoolReconciler) reconcileMachinePoolVersion(machinePoolScope *scope.RosaMachinePoolScope, ocmClient *ocm.Client, nodePool *cmv1.NodePool) error {
version := machinePoolScope.RosaMachinePool.Spec.Version
if version == "" {
version = machinePoolScope.ControlPlane.Spec.Version
}

if version == rosa.RawVersionID(nodePool.Version()) {
if version == "" || version == rosa.RawVersionID(nodePool.Version()) {
conditions.MarkFalse(machinePoolScope.RosaMachinePool, expinfrav1.RosaMachinePoolUpgradingCondition, "upgraded", clusterv1.ConditionSeverityInfo, "")
return nil
}
Expand Down Expand Up @@ -370,6 +371,11 @@ func (r *ROSAMachinePoolReconciler) updateNodePool(machinePoolScope *scope.RosaM

updatedNodePool, err := ocmClient.UpdateNodePool(machinePoolScope.ControlPlane.Status.ID, nodePoolSpec)
if err != nil {
conditions.MarkFalse(machinePoolScope.RosaMachinePool,
expinfrav1.RosaMachinePoolReadyCondition,
expinfrav1.RosaMachinePoolReconciliationFailedReason,
clusterv1.ConditionSeverityError,
"failed to update ROSAMachinePool: %s", err.Error())
return nil, fmt.Errorf("failed to update nodePool: %w", err)
}

Expand Down

0 comments on commit d60bc63

Please sign in to comment.