Skip to content

Commit

Permalink
RayService: Dev RayService CR and Controller logic (ray-project#287)
Browse files Browse the repository at this point in the history
* Implement RayService CRD and controller

* Update config and controller

* update

* update

* refactor

* goimports

* goimports

* address comments

* address comments

* address comments

* address comments

* address comments

* address comments

* address comments

* add unit tests

* fix ut

* Update yaml

* update ut

* update
  • Loading branch information
brucez-anyscale authored Jun 9, 2022
1 parent a793574 commit 5429751
Show file tree
Hide file tree
Showing 14 changed files with 12,856 additions and 23 deletions.
3 changes: 2 additions & 1 deletion ray-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ COMMIT_SHA1 := $(shell git rev-parse HEAD )
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:maxDescLen=100,trivialVersions=true,preserveUnknownFields=false,generateEmbeddedObjectMeta=true"
# Golang forbids converting float from Json to struct. Need allowDangerousTypes=true to unblock build.
CRD_OPTIONS ?= "crd:maxDescLen=100,trivialVersions=true,preserveUnknownFields=false,generateEmbeddedObjectMeta=true,allowDangerousTypes=true"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
68 changes: 66 additions & 2 deletions ray-operator/apis/ray/v1alpha1/rayservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,80 @@ import (
// 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.

type ServiceStatus string

const (
FailToGetOrCreateRayCluster ServiceStatus = "FailToGetOrCreateRayCluster"
WaitForDashboard ServiceStatus = "WaitForDashboard"
FailServeDeploy ServiceStatus = "FailServeDeploy"
FailGetServeDeploymentStatus ServiceStatus = "FailGetServeDeploymentStatus"
Running ServiceStatus = "Running"
Restarting ServiceStatus = "Restarting"
FailDeleteRayCluster ServiceStatus = "FailDeleteRayCluster"
)

// RayServiceSpec defines the desired state of RayService
type RayServiceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
ServeConfigSpecs []ServeConfigSpec `json:"serveConfigs,omitempty"`
RayClusterSpec RayClusterSpec `json:"rayClusterConfig,omitempty"`
}

// ServeConfigSpec defines the desired state of RayService
// Reference to https://docs.ray.io/en/latest/ray-core/package-ref.html#ray-remote.
type ServeConfigSpec struct {
Name string `json:"name"`
ImportPath string `json:"importPath"`
InitArgs []string `json:"initArgs,omitempty"`
InitKwargs map[string]string `json:"initKwargs,omitempty"`
NumReplicas *int32 `json:"numReplicas,omitempty"`
RoutePrefix string `json:"routePrefix,omitempty"`
MaxConcurrentQueries *int32 `json:"maxConcurrentQueries,omitempty"`
UserConfig map[string]string `json:"userConfig,omitempty"`
AutoscalingConfig map[string]string `json:"autoscalingConfig,omitempty"`
GracefulShutdownWaitLoopS *int32 `json:"gracefulShutdownWaitLoopS,omitempty"`
GracefulShutdownTimeoutS *int32 `json:"gracefulShutdownTimeoutS,omitempty"`
HealthCheckPeriodS *int32 `json:"healthCheckPeriodS,omitempty"`
HealthCheckTimeoutS *int32 `json:"healthCheckTimeoutS,omitempty"`
RayActorOptions RayActorOptionSpec `json:"rayActorOptions,omitempty"`
}

// RayActorOptionSpec defines the desired state of RayActor
type RayActorOptionSpec struct {
RuntimeEnv map[string][]string `json:"runtimeEnv,omitempty"`
NumCpus *float64 `json:"numCpus,omitempty"`
NumGpus *float64 `json:"numGpus,omitempty"`
Memory *int32 `json:"memory,omitempty"`
ObjectStoreMemory *int32 `json:"objectStoreMemory,omitempty"`
Resources map[string]string `json:"resources,omitempty"`
AcceleratorType string `json:"acceleratorType,omitempty"`
}

// RayServiceStatus defines the observed state of RayService
type RayServiceStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
ServiceStatus ServiceStatus `json:"serviceStatus,omitempty"`
ServeStatuses []ServeDeploymentStatus `json:"serveDeploymentStatuses,omitempty"`
RayClusterName string `json:"rayClusterName,omitempty"`
RayClusterStatus RayClusterStatus `json:"rayClusterStatus,omitempty"`
}

// ServeDeploymentStatuses defines the current states of all Serve Deployments
type ServeDeploymentStatuses struct {
Statuses []ServeDeploymentStatus `json:"statuses,omitempty"`
}

// ServeDeploymentStatus defines the current state of Serve Deployment
type ServeDeploymentStatus struct {
// Name, Status, Message are from Ray Dashboard to represent the state of a serve deployment.
Name string `json:"name,omitempty"`
// TODO: change status type to enum
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
// Keep track of how long the service is healthy.
// Update when Serve Deployment is healthy or first time convert to unhealthy from healthy.
HealthLastUpdateTime metav1.Time `json:"healthLastUpdateTime,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
Loading

0 comments on commit 5429751

Please sign in to comment.