Skip to content

Commit

Permalink
feat: add support for Ray (#1315)
Browse files Browse the repository at this point in the history
* feat: add support for Ray

- cleanup old component files: ray and dashboard
- rename function to be more generic
- status update on component for installedcomponent
- add e2e test
- move ireturn into golangci config

Signed-off-by: Wen Zhou <wenzhou@redhat.com>

---------

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw authored Oct 31, 2024
1 parent 7d4613c commit a1f0e62
Show file tree
Hide file tree
Showing 33 changed files with 727 additions and 600 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ linters-settings:
- stdlib
# also allow generics
- generic
- EventHandler # for ToOwner
revive:
rules:
- name: dot-imports
Expand Down
3 changes: 2 additions & 1 deletion apis/components/v1/dashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
)

const (
DashboardComponentName = "dashboard"
// DashboardInstanceName the name of the Dashboard instance singleton.
// It must match what is set in the XValidation below.
// value should match whats set in the XValidation below
DashboardInstanceName = "default-dashboard"
DashboardKind = "Dashboard"
)
Expand Down
54 changes: 34 additions & 20 deletions apis/components/v1/ray_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,21 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// RaySpec defines the desired state of Ray
type RaySpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of Ray. Edit ray_types.go to remove/update
Foo string `json:"foo,omitempty"`
}
const (
RayComponentName = "ray"
// value should match whats set in the XValidation below
RayInstanceName = "default-ray"
RayKind = "Ray"
)

// RayStatus defines the observed state of Ray
type RayStatus struct {
components.Status `json:",inline"`
}
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default-ray'",message="Ray name must be default-ray"
// +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"

// Ray is the Schema for the rays API
type Ray struct {
Expand All @@ -51,16 +46,21 @@ type Ray struct {
Status RayStatus `json:"status,omitempty"`
}

func (c *Ray) GetDevFlags() *components.DevFlags {
return nil
// RaySpec defines the desired state of Ray
type RaySpec struct {
RayCommonSpec `json:",inline"`
}

func (c *Ray) GetStatus() *components.Status {
return &c.Status.Status
type RayCommonSpec struct {
components.DevFlagsSpec `json:",inline"`
}

// +kubebuilder:object:root=true
// RayStatus defines the observed state of Ray
type RayStatus struct {
components.Status `json:",inline"`
}

// +kubebuilder:object:root=true
// RayList contains a list of Ray
type RayList struct {
metav1.TypeMeta `json:",inline"`
Expand All @@ -71,3 +71,17 @@ type RayList struct {
func init() {
SchemeBuilder.Register(&Ray{}, &RayList{})
}

func (c *Ray) GetDevFlags() *components.DevFlags {
return c.Spec.DevFlags
}
func (c *Ray) GetStatus() *components.Status {
return &c.Status.Status
}

// DSCRay contains all the configuration exposed in DSC instance for Ray component
type DSCRay struct {
components.ManagementSpec `json:",inline"`
// configuration fields common across components
RayCommonSpec `json:",inline"`
}
36 changes: 35 additions & 1 deletion apis/components/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions apis/datasciencecluster/v1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/components/kueue"
"github.com/opendatahub-io/opendatahub-operator/v2/components/modelmeshserving"
"github.com/opendatahub-io/opendatahub-operator/v2/components/modelregistry"
"github.com/opendatahub-io/opendatahub-operator/v2/components/ray"
"github.com/opendatahub-io/opendatahub-operator/v2/components/trainingoperator"
"github.com/opendatahub-io/opendatahub-operator/v2/components/trustyai"
"github.com/opendatahub-io/opendatahub-operator/v2/components/workbenches"
Expand Down Expand Up @@ -75,7 +74,7 @@ type Components struct {
CodeFlare codeflare.CodeFlare `json:"codeflare,omitempty"`

// Ray component configuration.
Ray ray.Ray `json:"ray,omitempty"`
Ray componentsv1.DSCRay `json:"ray,omitempty"`

// TrustyAI component configuration.
TrustyAI trustyai.TrustyAI `json:"trustyai,omitempty"`
Expand Down
20 changes: 6 additions & 14 deletions bundle/manifests/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 @@ -74,20 +78,6 @@ spec:
type: object
type: array
type: object
managementState:
description: |-
Set to one of the following values:
- "Managed" : the operator is actively managing the component and trying to keep it active.
It will only upgrade the component if it is safe to do so
- "Removed" : the operator is actively managing the component and will not install it,
or if it is installed, the operator will try to remove it
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
status:
description: DashboardStatus defines the observed state of Dashboard
Expand Down Expand Up @@ -153,6 +143,8 @@ spec:
type: integer
phase:
type: string
url:
type: string
type: object
type: object
x-kubernetes-validations:
Expand Down
44 changes: 39 additions & 5 deletions bundle/manifests/components.opendatahub.io_rays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ spec:
singular: ray
scope: Cluster
versions:
- name: v1
- additionalPrinterColumns:
- description: Ready
jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- description: Reason
jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
name: v1
schema:
openAPIV3Schema:
description: Ray is the Schema for the rays API
Expand All @@ -39,10 +48,32 @@ spec:
spec:
description: RaySpec defines the desired state of Ray
properties:
foo:
description: Foo is an example field of Ray. Edit ray_types.go to
remove/update
type: string
devFlags:
description: Add developer fields
properties:
manifests:
description: List of custom manifests for the given component
items:
properties:
contextDir:
default: manifests
description: contextDir is the relative path to the folder
containing manifests in a repository, default value "manifests"
type: string
sourcePath:
default: ""
description: 'sourcePath is the subpath within contextDir
where kustomize builds start. Examples include any sub-folder
or path: `base`, `overlays/dev`, `default`, `odh` etc.'
type: string
uri:
default: ""
description: uri is the URI point to a git repo with tag/branch.
e.g. https://github.com/org/repo/tarball/<tag/branch>
type: string
type: object
type: array
type: object
type: object
status:
description: RayStatus defines the observed state of Ray
Expand Down Expand Up @@ -110,6 +141,9 @@ spec:
type: string
type: object
type: object
x-kubernetes-validations:
- message: Ray name must be default-ray
rule: self.metadata.name == 'default-ray'
served: true
storage: true
subresources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ metadata:
categories: AI/Machine Learning, Big Data
certified: "False"
containerImage: quay.io/opendatahub/opendatahub-operator:v2.19.0
createdAt: "2024-10-24T09:24:00Z"
createdAt: "2024-10-30T14:18:10Z"
olm.skipRange: '>=1.0.0 <2.19.0'
operators.operatorframework.io/builder: operator-sdk-v1.31.0
operators.operatorframework.io/internal-objects: '["featuretrackers.features.opendatahub.io",
Expand All @@ -129,10 +129,6 @@ spec:
displayName: Dashboard
kind: Dashboard
name: dashboards.components.opendatahub.io
specDescriptors:
- description: Add developer fields
displayName: Dev Flags
path: devFlags
version: v1
- description: DataScienceCluster is the Schema for the datascienceclusters API.
displayName: Data Science Cluster
Expand Down
Loading

0 comments on commit a1f0e62

Please sign in to comment.