Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component reconciliation pipeline framework #1320

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apis/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package components
import (
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// ManagementSpec struct defines the component's management configuration.
Expand Down Expand Up @@ -75,3 +76,13 @@ type Status struct {
type WithStatus interface {
GetStatus() *Status
}

type WithDevFlags interface {
GetDevFlags() *DevFlags
}

type ComponentObject interface {
client.Object
WithDevFlags
WithStatus
}
4 changes: 4 additions & 0 deletions apis/components/v1/codeflare_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type CodeFlare struct {
Status CodeFlareStatus `json:"status,omitempty"`
}

func (c *CodeFlare) GetDevFlags() *components.DevFlags {
return nil
}

func (c *CodeFlare) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
11 changes: 10 additions & 1 deletion apis/components/v1/dashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import (
)

const (
// value should match whats set in the XValidation below
// DashboardInstanceName the name of the Dashboard instance singleton.
// It must match what is set in the XValidation below.
DashboardInstanceName = "default-dashboard"
DashboardKind = "Dashboard"
)

// DashboardCommonSpec spec defines the shared desired state of Dashboard
Expand All @@ -43,6 +45,8 @@ type DashboardSpec struct {
// DashboardStatus defines the observed state of Dashboard
type DashboardStatus struct {
components.Status `json:",inline"`

URL string `json:"url,omitempty"`
}

// +kubebuilder:object:root=true
Expand All @@ -51,6 +55,7 @@ type DashboardStatus struct {
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-dashboard'",message="Dashboard name must be default-dashboard"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="Ready"
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`,description="Reason"
// +kubebuilder:printcolumn:name="URL",type=string,JSONPath=`.status.url`,description="URL"

// Dashboard is the Schema for the dashboards API
type Dashboard struct {
Expand All @@ -61,6 +66,10 @@ type Dashboard struct {
Status DashboardStatus `json:"status,omitempty"`
}

func (c *Dashboard) GetDevFlags() *components.DevFlags {
return c.Spec.DevFlags
}

func (c *Dashboard) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/datasciencepipelines_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type DataSciencePipelines struct {
Status DataSciencePipelinesStatus `json:"status,omitempty"`
}

func (c *DataSciencePipelines) GetDevFlags() *components.DevFlags {
return nil
}

func (c *DataSciencePipelines) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/kserve_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type Kserve struct {
Status KserveStatus `json:"status,omitempty"`
}

func (c *Kserve) GetDevFlags() *components.DevFlags {
return nil
}

func (c *Kserve) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/kueue_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type Kueue struct {
Status KueueStatus `json:"status,omitempty"`
}

func (c *Kueue) GetDevFlags() *components.DevFlags {
return nil
}

func (c *Kueue) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/modelmeshserving_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type ModelMeshServing struct {
Status ModelMeshServingStatus `json:"status,omitempty"`
}

func (c *ModelMeshServing) GetDevFlags() *components.DevFlags {
return nil
}

func (c *ModelMeshServing) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/modelregistry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type ModelRegistry struct {
Status ModelRegistryStatus `json:"status,omitempty"`
}

func (c *ModelRegistry) GetDevFlags() *components.DevFlags {
return nil
}

func (c *ModelRegistry) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/ray_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type Ray struct {
Status RayStatus `json:"status,omitempty"`
}

func (c *Ray) GetDevFlags() *components.DevFlags {
return nil
}

func (c *Ray) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/trainingoperator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type TrainingOperator struct {
Status TrainingOperatorStatus `json:"status,omitempty"`
}

func (c *TrainingOperator) GetDevFlags() *components.DevFlags {
return nil
}

func (c *TrainingOperator) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/trustyai_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type TrustyAI struct {
Status TrustyAIStatus `json:"status,omitempty"`
}

func (c *TrustyAI) GetDevFlags() *components.DevFlags {
return nil
}

func (c *TrustyAI) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
4 changes: 4 additions & 0 deletions apis/components/v1/workbenches_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type Workbenches struct {
Status WorkbenchesStatus `json:"status,omitempty"`
}

func (c *Workbenches) GetDevFlags() *components.DevFlags {
return nil
}

func (c *Workbenches) GetStatus() *components.Status {
return &c.Status.Status
}
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/components.opendatahub.io_dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ spec:
jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
- description: URL
jsonPath: .status.url
name: URL
type: string
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -139,6 +143,8 @@ spec:
type: integer
phase:
type: string
url:
type: string
type: object
type: object
x-kubernetes-validations:
Expand Down
49 changes: 49 additions & 0 deletions controllers/components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dashboard

import (
"fmt"

operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

componentsv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1"
dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
odhdeploy "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/annotations"
)

func Init(platform cluster.Platform) error {
mi := defaultManifestInfo(platform)

if err := odhdeploy.ApplyParams(mi.String(), imagesMap); err != nil {
return fmt.Errorf("failed to update images on path %s: %w", manifestPaths[platform], err)
}

return nil
}

func GetDashboard(dsc *dscv1.DataScienceCluster) *componentsv1.Dashboard {
dashboardAnnotations := make(map[string]string)

switch dsc.Spec.Components.Dashboard.ManagementState {
case operatorv1.Managed, operatorv1.Removed:
dashboardAnnotations[annotations.ManagementStateAnnotation] = string(dsc.Spec.Components.Dashboard.ManagementState)
default: // Force and Unmanaged case for unknown values, we do not support these yet
dashboardAnnotations[annotations.ManagementStateAnnotation] = "Unknown"
}

return &componentsv1.Dashboard{
TypeMeta: metav1.TypeMeta{
Kind: componentsv1.DashboardKind,
APIVersion: componentsv1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: componentsv1.DashboardInstanceName,
Annotations: dashboardAnnotations,
},
Spec: componentsv1.DashboardSpec{
DashboardCommonSpec: dsc.Spec.Components.Dashboard.DashboardCommonSpec,
},
}
}
Loading