Skip to content

Commit

Permalink
fix: update release version in DSCI and DSC .status for upgrade case
Browse files Browse the repository at this point in the history
- DSCI: if current version is not matching, update it
- DSC: in both reconcile pass and fail case, update it

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Oct 9, 2024
1 parent 6134496 commit 752e704
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R
status.SetCompleteCondition(&saved.Status.Conditions, status.ReconcileCompletedWithComponentErrors,
fmt.Sprintf("DataScienceCluster resource reconciled with component errors: %v", componentErrors))
saved.Status.Phase = status.PhaseReady
saved.Status.Release = currentOperatorRelease
})
if err != nil {
log.Error(err, "failed to update DataScienceCluster conditions with incompleted reconciliation")
Expand All @@ -270,6 +271,7 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R
instance, err = status.UpdateWithRetry(ctx, r.Client, instance, func(saved *dscv1.DataScienceCluster) {
status.SetCompleteCondition(&saved.Status.Conditions, status.ReconcileCompleted, "DataScienceCluster resource reconciled successfully")
saved.Status.Phase = status.PhaseReady
saved.Status.Release = currentOperatorRelease
})

if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions controllers/dscinitialization/dscinitialization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ func (r *DSCInitializationReconciler) Reconcile(ctx context.Context, req ctrl.Re
}
}

// upgrade case to update release version in status
if !instance.Status.Release.Version.Equals(currentOperatorRelease.Version.Version) {
message := "Updating DSCInitialization status"
instance, err := status.UpdateWithRetry(ctx, r.Client, instance, func(saved *dsciv1.DSCInitialization) {
saved.Status.Release = currentOperatorRelease
})
if err != nil {
log.Error(err, "Failed to update release version for DSCInitialization resource.", "DSCInitialization", req.Namespace, "Request.Name", req.Name)
r.Recorder.Eventf(instance, corev1.EventTypeWarning, "DSCInitializationReconcileError",
"%s for instance %s", message, instance.Name)
return reconcile.Result{}, err
}
}

// Check namespace is not exist, then create
namespace := instance.Spec.ApplicationsNamespace
err := r.createOdhNamespace(ctx, instance, namespace, platform)
Expand Down

0 comments on commit 752e704

Please sign in to comment.