diff --git a/controllers/datasciencecluster/datasciencecluster_controller.go b/controllers/datasciencecluster/datasciencecluster_controller.go index c7d4a20a68e..e250980d58d 100644 --- a/controllers/datasciencecluster/datasciencecluster_controller.go +++ b/controllers/datasciencecluster/datasciencecluster_controller.go @@ -86,7 +86,7 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R r.Log.Info("Reconciling DataScienceCluster resources", "Request.Name", req.Name) // Get information on version - currentOperatorReleaseVersion, err := cluster.GetRelease(ctx, r.Client) + currentOperatorRelease, err := cluster.GetRelease(ctx, r.Client) if err != nil { r.Log.Error(err, "failed to get operator release version") return ctrl.Result{}, err @@ -227,7 +227,7 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R instance, err = status.UpdateWithRetry(ctx, r.Client, instance, func(saved *dscv1.DataScienceCluster) { status.SetProgressingCondition(&saved.Status.Conditions, reason, message) saved.Status.Phase = status.PhaseProgressing - saved.Status.Release = currentOperatorReleaseVersion + saved.Status.Release = currentOperatorRelease }) if err != nil { _ = r.reportError(err, instance, fmt.Sprintf("failed to add conditions to status of DataScienceCluster resource name %s", req.Name)) @@ -251,6 +251,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 { r.Log.Error(err, "failed to update DataScienceCluster conditions with incompleted reconciliation") @@ -265,6 +266,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 { diff --git a/controllers/dscinitialization/dscinitialization_controller.go b/controllers/dscinitialization/dscinitialization_controller.go index 9e73747a39b..62693aa1449 100644 --- a/controllers/dscinitialization/dscinitialization_controller.go +++ b/controllers/dscinitialization/dscinitialization_controller.go @@ -78,7 +78,7 @@ type DSCInitializationReconciler struct { func (r *DSCInitializationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { //nolint:funlen,gocyclo,maintidx r.Log.Info("Reconciling DSCInitialization.", "DSCInitialization Request.Name", req.Name) - currentOperatorReleaseVersion, err := cluster.GetRelease(ctx, r.Client) + currentOperatorRelease, err := cluster.GetRelease(ctx, r.Client) if err != nil { r.Log.Error(err, "failed to get operator release version") return ctrl.Result{}, err @@ -141,7 +141,7 @@ func (r *DSCInitializationReconciler) Reconcile(ctx context.Context, req ctrl.Re instance, err = status.UpdateWithRetry(ctx, r.Client, instance, func(saved *dsciv1.DSCInitialization) { status.SetProgressingCondition(&saved.Status.Conditions, reason, message) saved.Status.Phase = status.PhaseProgressing - saved.Status.Release = currentOperatorReleaseVersion + saved.Status.Release = currentOperatorRelease }) if err != nil { r.Log.Error(err, "Failed to add conditions to status of DSCInitialization resource.", "DSCInitialization", req.Namespace, "Request.Name", req.Name) @@ -151,6 +151,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 { + r.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)