Skip to content

Commit

Permalink
Sync with upstream
Browse files Browse the repository at this point in the history
Add ODHDashboardconfig in dasboard component

(cherry picked from commit 2a8757d)

Add admin group for downstream

(cherry picked from commit 8a72ab9)

Add ImageParams for kuberay and codeflare

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
(cherry picked from commit ab2fdab)

Add consolelink for new operator only on cloudserver cluster

- Move from util to common for ReplaceStringsInFile

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
(cherry picked from commit 80c69bb)

Fix: version number and add description (opendatahub-io#388)

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
(cherry picked from commit 76ee489)

Add ImageParams map for KServe

- explainer images will later be removed and function move to trustyai

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
(cherry picked from commit 499d9e5)

Update labels

(cherry picked from commit a9b474f)

Shared resources should not be deleted

(cherry picked from commit 8739f65)

Remove dependency of deployment manifests on other components (opendatahub-io#387)

(cherry picked from commit 7a3a9f7)
  • Loading branch information
VaishnaviHire committed Jul 31, 2023
1 parent a478e05 commit 39c91d0
Show file tree
Hide file tree
Showing 15 changed files with 718 additions and 65 deletions.
6 changes: 4 additions & 2 deletions apis/datasciencecluster/v1alpha1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ type Components struct {
// Kserve component configuration
Kserve kserve.Kserve `json:"kserve,omitempty"`

// CodeFlare component configuration
// CodeFlare component configuration.
// Require CodeFlare operator to be installed before enable component
CodeFlare codeflare.CodeFlare `json:"codeflare,omitempty"`

// Ray component configuration
// Ray component configuration.
// Require CodeFlare operator to be installed before enable component
Ray ray.Ray `json:"ray,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ spec:
description: Override and fine tune specific component configurations.
properties:
codeflare:
description: CodeFlare component configuration
description: CodeFlare component configuration Require CodeFlare
operator to be installed before enable component
properties:
enabled:
description: Set to "true" to enable component, "false" to
Expand Down Expand Up @@ -89,7 +90,8 @@ spec:
- enabled
type: object
ray:
description: Ray component configuration
description: Ray component configuration Require CodeFlare operator
to be installed before enable component
properties:
enabled:
description: Set to "true" to enable component, "false" to
Expand Down
512 changes: 512 additions & 0 deletions bundle/manifests/opendatahub-operator.clusterserviceversion.yaml

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import (

const (
ComponentName = "codeflare"
CodeflarePath = deploy.DefaultManifestPath + "/" + "codeflare-stack" + "/base"
CodeflarePath = deploy.DefaultManifestPath + "/" + "codeflare-stack/base"
)

var imageParamMap = map[string]string{}
var imageParamMap = map[string]string{
"odh-codeflare-operator-image": "RELATED_IMAGE_ODH_CODEFLARE_OPERATOR_IMAGE",
"odh-mcad-controller-image": "RELATED_IMAGE_ODH_MCAD_CONTROLLER_IMAGE",
}

type CodeFlare struct {
components.Component `json:""`
Expand Down
35 changes: 34 additions & 1 deletion components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package dashboard

import (
"fmt"

"context"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/common"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
routev1 "github.com/openshift/api/route/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"strings"
)

const (
Expand All @@ -17,6 +22,7 @@ const (
PathISVAddOn = deploy.DefaultManifestPath + "/" + ComponentName + "/overlays/apps-addon"
PathOVMS = deploy.DefaultManifestPath + "/" + ComponentName + "/modelserving"
PathODHDashboardConfig = deploy.DefaultManifestPath + "/" + ComponentName + "/odhdashboardconfig"
PathConsoleLink = deploy.DefaultManifestPath + "/" + ComponentName + "/consolelink"
)

var imageParamMap = map[string]string{
Expand Down Expand Up @@ -129,11 +135,38 @@ func (d *Dashboard) ReconcileComponent(owner metav1.Object, cli client.Client, s
if err != nil {
return fmt.Errorf("failed to set dashboard ISV from %s: %v", PathISVAddOn, err)
}
// ConsoleLink handling
consoleRoute := &routev1.Route{}
err = cli.Get(context.TODO(), client.ObjectKey{Name: "console", Namespace: "openshift-console"}, consoleRoute)
if err != nil && !apierrs.IsNotFound(err) {
return fmt.Errorf("Error getting console route URL : %v", err)
}
domainIndex := strings.Index(consoleRoute.Spec.Host, ".")
consolelinkDomain := consoleRoute.Spec.Host[domainIndex+1:]
err = common.ReplaceStringsInFile(PathConsoleLink, map[string]string{
"<rhods-dashboard-url>": "https://rhods-dashboard-" + namespace + consolelinkDomain,
})
if err != nil {
return fmt.Errorf("Error replacing with correct dashboard url for ConsoleLink: %v", err)
}
err = deploy.DeployManifestsFromPath(owner, cli, ComponentName,
PathConsoleLink,
namespace,
scheme, enabled)
if err != nil {
return fmt.Errorf("failed to set dashboard consolelink from %s", PathConsoleLink)
}
err = deploy.DeployManifestsFromPath(owner, cli, ComponentName,
PathConsoleLink,
namespace,
scheme, enabled)
if err != nil {
return fmt.Errorf("failed to set dashboard consolelink from %s", PathConsoleLink)
}
return err
default:
return nil
}

}

func (in *Dashboard) DeepCopyInto(out *Dashboard) {
Expand Down
7 changes: 6 additions & 1 deletion components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const (
Path = deploy.DefaultManifestPath + "/" + ComponentName + "/base"
)

var imageParamMap = map[string]string{}
var imageParamMap = map[string]string{
"kserve-router": "RELATED_IMAGE_ODH_KSERVE_ROUTE_IMAGE",
"kserve-agent": "RELATED_IMAGE_ODH_KSERVE_AGENT_IMAGE",
"kserve-controller": "RELATED_IMAGE_ODH_KSERVE_CONTROLLER_IMAGE",
"kserve-storage-initializer": "RELATED_IMAGE_ODH_KSERVE_STORAGE_INITIALIZER_IMAGE",
}

type Kserve struct {
components.Component `json:""`
Expand Down
6 changes: 4 additions & 2 deletions components/ray/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (

const (
ComponentName = "ray"
RayPath = deploy.DefaultManifestPath + "/" + "ray/operator" + "/base"
RayPath = deploy.DefaultManifestPath + "/" + "ray/operator/base"
)

var imageParamMap = map[string]string{}
var imageParamMap = map[string]string{
"odh-kuberay-operator-controller-image": "RELATED_IMAGE_ODH_KUBERAY_OPERATOR_CONTROLLER_IMAGE",
}

type Ray struct {
components.Component `json:""`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ spec:
description: Override and fine tune specific component configurations.
properties:
codeflare:
description: CodeFlare component configuration
description: CodeFlare component configuration Require CodeFlare
operator to be installed before enable component
properties:
enabled:
description: Set to "true" to enable component, "false" to
Expand Down Expand Up @@ -90,7 +91,8 @@ spec:
- enabled
type: object
ray:
description: Ray component configuration
description: Ray component configuration Require CodeFlare operator
to be installed before enable component
properties:
enabled:
description: Set to "true" to enable component, "false" to
Expand Down
101 changes: 66 additions & 35 deletions controllers/datasciencecluster/datasciencecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package datasciencecluster
import (
"context"
"fmt"
"github.com/opendatahub-io/opendatahub-operator/v2/components/codeflare"
"time"

"github.com/go-logr/logr"
"k8s.io/client-go/util/retry"

"time"

dsc "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1alpha1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/components/dashboard"
Expand Down Expand Up @@ -120,42 +120,75 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R
_ = r.reportError(err, instance, "error updating list of components in the CR")
return ctrl.Result{}, err
}
// // Ensure all omitted components show up as explicitly disabled
// instance, err = r.updateComponents(instance)
// if err != nil {
// _ = r.reportError(err, instance, "error updating list of components in the CR")
// return ctrl.Result{}, err
// }

// Initialize error list, instead of returning errors after every component is deployed
componentErrorList := make(map[string]error)

// reconcile dashboard component
var val ctrl.Result
if instance, val, err = r.reconcileSubComponent(instance, dashboard.ComponentName, instance.Spec.Components.Dashboard.Enabled,
if instance, err = r.reconcileSubComponent(instance, dashboard.ComponentName, instance.Spec.Components.Dashboard.Enabled,
&(instance.Spec.Components.Dashboard), ctx); err != nil {
// no need to log any errors as this is done in the reconcileSubComponent method
return val, err
componentErrorList[dashboard.ComponentName] = err
}

// reconcile DataSciencePipelines component
if instance, val, err = r.reconcileSubComponent(instance, datasciencepipelines.ComponentName, instance.Spec.Components.DataSciencePipelines.Enabled,
if instance, err = r.reconcileSubComponent(instance, datasciencepipelines.ComponentName, instance.Spec.Components.DataSciencePipelines.Enabled,
&(instance.Spec.Components.DataSciencePipelines), ctx); err != nil {
// no need to log any errors as this is done in the reconcileSubComponent method
return val, err
componentErrorList[datasciencepipelines.ComponentName] = err
}

// reconcile Workbench component
if instance, val, err = r.reconcileSubComponent(instance, workbenches.ComponentName, instance.Spec.Components.Workbenches.Enabled,
if instance, err = r.reconcileSubComponent(instance, workbenches.ComponentName, instance.Spec.Components.Workbenches.Enabled,
&(instance.Spec.Components.Workbenches), ctx); err != nil {
// no need to log any errors as this is done in the reconcileSubComponent method
return val, err
componentErrorList[workbenches.ComponentName] = err
}

// reconcile Kserve component
if instance, val, err = r.reconcileSubComponent(instance, kserve.ComponentName, instance.Spec.Components.Kserve.Enabled, &(instance.Spec.Components.Kserve), ctx); err != nil {
if instance, err = r.reconcileSubComponent(instance, kserve.ComponentName, instance.Spec.Components.Kserve.Enabled, &(instance.Spec.Components.Kserve), ctx); err != nil {
// no need to log any errors as this is done in the reconcileSubComponent method
return val, err
componentErrorList[kserve.ComponentName] = err
}

// reconcile ModelMesh component
if instance, val, err = r.reconcileSubComponent(instance, modelmeshserving.ComponentName, instance.Spec.Components.ModelMeshServing.Enabled,
if instance, err = r.reconcileSubComponent(instance, modelmeshserving.ComponentName, instance.Spec.Components.ModelMeshServing.Enabled,
&(instance.Spec.Components.ModelMeshServing), ctx); err != nil {
// no need to log any errors as this is done in the reconcileSubComponent method
return val, err
componentErrorList[modelmeshserving.ComponentName] = err
}

// reconcile CodeFlare component
if instance, err = r.reconcileSubComponent(instance, codeflare.ComponentName, instance.Spec.Components.CodeFlare.Enabled, &(instance.Spec.Components.CodeFlare), ctx); err != nil {
// no need to log any errors as this is done in the reconcileSubComponent method
componentErrorList[codeflare.ComponentName] = err
}

// Process errors for components
if componentErrorList != nil && len(componentErrorList) != 0 {
r.Log.Info("DataScienceCluster Deployment Incomplete.")
instance, err = r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
status.SetCompleteCondition(&saved.Status.Conditions, status.ReconcileCompletedWithComponentErrors,
fmt.Sprintf("DataScienceCluster resource reconciled with component errors: %v", fmt.Sprint(componentErrorList)))
saved.Status.Phase = status.PhaseReady
})
r.Recorder.Eventf(instance, corev1.EventTypeNormal, "DataScienceClusterComponentFailures",
"DataScienceCluster instance %s created, but have some failures in component %v", instance.Name, fmt.Sprint(componentErrorList))
return ctrl.Result{RequeueAfter: time.Second * 10}, fmt.Errorf(fmt.Sprint(componentErrorList))
}

// reconcile Ray component
// if instance, val, err = r.reconcileSubComponent(instance, ray.ComponentName, instance.Spec.Components.Ray.Enabled, &(instance.Spec.Components.Ray), ctx); err != nil {
// // no need to log any errors as this is done in the reconcileSubComponent method
// return val, err
// }

// finalize reconciliation
instance, err = r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
status.SetCompleteCondition(&saved.Status.Conditions, status.ReconcileCompleted, "DataScienceCluster resource reconciled successfully")
Expand All @@ -164,16 +197,17 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R
if err != nil {
r.Log.Error(err, "failed to update DataScienceCluster conditions after successfuly completed reconciliation")
return ctrl.Result{}, err
} else {
r.Log.Info("DataScienceCluster Deployment Completed.")
r.Recorder.Eventf(instance, corev1.EventTypeNormal, "DataScienceClusterCreationSuccessful",
"DataScienceCluster instance %s created and deployed successfully", instance.Name)
}

r.Log.Info("DataScienceCluster Deployment Completed.")
r.Recorder.Eventf(instance, corev1.EventTypeNormal, "DataScienceClusterCreationSuccessful",
"DataScienceCluster instance %s created and deployed successfully", instance.Name)

return ctrl.Result{}, nil
}

func (r *DataScienceClusterReconciler) reconcileSubComponent(instance *dsc.DataScienceCluster, componentName string, enabled bool,
component components.ComponentInterface, ctx context.Context) (*dsc.DataScienceCluster, ctrl.Result, error) {
component components.ComponentInterface, ctx context.Context) (*dsc.DataScienceCluster, error) {

// First set contidions to reflect a component is about to be reconciled
instance, err := r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
Expand All @@ -185,9 +219,7 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(instance *dsc.DataS
})
if err != nil {
instance = r.reportError(err, instance, "failed to update DataScienceCluster conditions before reconciling "+componentName)
return instance, ctrl.Result{
// Retry after failure until success.
RequeueAfter: time.Second * 10}, err
return instance, err
}

// Reconcile component
Expand All @@ -198,14 +230,12 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(instance *dsc.DataS
instance = r.reportError(err, instance, "failed to reconcile "+componentName+" on DataScienceCluster")
instance, _ = r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
if enabled {
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileFailed, "Component reconciliation failed", corev1.ConditionFalse)
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileFailed, fmt.Sprintf("Component reconciliation failed: %v", err), corev1.ConditionFalse)
} else {
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileFailed, "Component removal failed", corev1.ConditionFalse)
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileFailed, fmt.Sprintf("Component removal failed: %v", err), corev1.ConditionFalse)
}
})
return instance, ctrl.Result{
// Retry after failure until success.
RequeueAfter: time.Second * 10}, err
return instance, err
} else {
// reconciliation succeeded: update status accordingly
instance, err = r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
Expand All @@ -221,23 +251,24 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(instance *dsc.DataS
})
if err != nil {
instance = r.reportError(err, instance, "failed to update DataScienceCluster status after reconciling "+componentName)
return instance, ctrl.Result{}, err
return instance, err
}
}
return instance, ctrl.Result{}, nil
return instance, nil
}

func (r *DataScienceClusterReconciler) reportError(err error, instance *dsc.DataScienceCluster, message string) *dsc.DataScienceCluster {
r.Log.Error(err, message, "instance.Name", instance.Name)
r.Recorder.Eventf(instance, corev1.EventTypeWarning, "DataScienceClusterReconcileError",
"%s for instance %s", message, instance.Name)
instance, err = r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
status.SetErrorCondition(&saved.Status.Conditions, status.ReconcileFailed, fmt.Sprintf("%s : %v", message, err))
saved.Status.Phase = status.PhaseError
})
if err != nil {
r.Log.Error(err, "failed to update DataScienceCluster status after error", "instance.Name", instance.Name)
}
// TODO:Set error phase only for creation/deletion errors of DSC CR
//instance, err = r.updateStatus(instance, func(saved *dsc.DataScienceCluster) {
// status.SetErrorCondition(&saved.Status.Conditions, status.ReconcileFailed, fmt.Sprintf("%s : %v", message, err))
// saved.Status.Phase = status.PhaseError
//})
//if err != nil {
// r.Log.Error(err, "failed to update DataScienceCluster status after error", "instance.Name", instance.Name)
//}
return instance
}

Expand Down
Loading

0 comments on commit 39c91d0

Please sign in to comment.