Skip to content

Commit

Permalink
fix: status update on component for installedcomponent
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Oct 24, 2024
1 parent e88244a commit 0980862
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions controllers/datasciencecluster/datasciencecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,21 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R
var componentErrors *multierror.Error

// Deploy Dashboard
dashboardRec := func() error {
dashboardRec := func() (error, bool) {
// Create the Dashboard instance
dashboard := dashboardctrl.GetComponentCR(instance)
// Reconcile component by set owner or delete it
return r.apply(ctx, instance, dashboard)
return r.apply(ctx, instance, dashboard), instance.Spec.Components.Dashboard.ManagementState == operatorv1.Managed
}
if instance, err = r.ReconcileComponent(ctx, instance, componentsv1.DashboardComponentName, dashboardRec); err != nil {
componentErrors = multierror.Append(componentErrors, err)
}
// Deploy Ray
rayRec := func() error {
rayRec := func() (error, bool) {
// Create the Dashboard instance
ray := rayctrl.GetComponentCR(instance)
// Reconcile component by set owner or delete it
return r.apply(ctx, instance, ray)
return r.apply(ctx, instance, ray), instance.Spec.Components.Ray.ManagementState == operatorv1.Managed
}
if instance, err = r.ReconcileComponent(ctx, instance, componentsv1.RayComponentName, rayRec); err != nil {
componentErrors = multierror.Append(componentErrors, err)
Expand Down Expand Up @@ -303,7 +303,7 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R
return ctrl.Result{}, nil
}

type ComponentHandler func() error
type ComponentHandler func() (error, bool)

// TODO: make it generic for all components.
func (r *DataScienceClusterReconciler) ReconcileComponent(
Expand All @@ -314,7 +314,8 @@ func (r *DataScienceClusterReconciler) ReconcileComponent(
) (*dscv1.DataScienceCluster, error) {
r.Log.Info("Starting reconciliation of component: " + componentName)

enabled := instance.Spec.Components.Dashboard.ManagementState == operatorv1.Managed
err, enabled := componentRec()

_, isExistStatus := instance.Status.InstalledComponents[componentName]

if !isExistStatus {
Expand All @@ -331,8 +332,6 @@ func (r *DataScienceClusterReconciler) ReconcileComponent(
}
}

err := componentRec()

if err != nil {
r.Log.Error(err, "Failed to reconcile component: "+componentName)
instance = r.reportError(err, instance, fmt.Sprintf("failed to reconcile %s on DataScienceCluster", componentName))
Expand Down

0 comments on commit 0980862

Please sign in to comment.