Documentation ¶
Index ¶
- Constants
- Variables
- func Before(value string, a string) string
- func CalculateAvailableReplicas(pods corev1.PodList) int32
- func CalculateDesiredReplicas(cluster *rayv1.RayCluster) int32
- func CalculateDesiredResources(cluster *rayv1.RayCluster) corev1.ResourceList
- func CalculateMaxReplicas(cluster *rayv1.RayCluster) int32
- func CalculateMinReplicas(cluster *rayv1.RayCluster) int32
- func CalculateMinResources(cluster *rayv1.RayCluster) corev1.ResourceList
- func CheckAllPodsRunning(runningPods corev1.PodList) bool
- func CheckLabel(s string) string
- func CheckName(s string) string
- func CompareJsonStruct(objA interface{}, objB interface{}) bool
- func Contains(elems []string, searchTerm string) bool
- func ConvertUnixTimeToMetav1Time(unixTime int64) *metav1.Time
- func ExtractRayIPFromFQDN(fqdnRayIP string) string
- func FetchHeadServiceURL(ctx context.Context, log *logr.Logger, cli client.Client, ...) (string, error)
- func FilterContainerByName(containers []corev1.Container, name string) (corev1.Container, error)
- func FindContainerPort(container *corev1.Container, portName string, defaultPort int) int
- func FormatInt32(n int32) string
- func GenerateFQDNServiceName(cluster rayv1.RayCluster, namespace string) string
- func GenerateHeadServiceName(crdType CRDType, clusterSpec rayv1.RayClusterSpec, ownerName string) (string, error)
- func GenerateIdentifier(clusterName string, nodeType rayv1.RayNodeType) string
- func GenerateIngressName(clusterName string) string
- func GenerateJsonHash(obj interface{}) (string, error)
- func GenerateRayClusterName(serviceName string) string
- func GenerateRayJobId(rayjob string) string
- func GenerateRouteName(clusterName string) string
- func GenerateServeServiceLabel(serviceName string) string
- func GenerateServeServiceName(serviceName string) string
- func GetClusterDomainName() string
- func GetHeadGroupServiceAccountName(cluster *rayv1.RayCluster) string
- func GetNamespace(metaData metav1.ObjectMeta) string
- func GetWorkerGroupDesiredReplicas(workerGroupSpec rayv1.WorkerGroupSpec) int32
- func IsCreated(pod *corev1.Pod) bool
- func IsRunningAndReady(pod *corev1.Pod) bool
- func PodNotMatchingTemplate(pod corev1.Pod, template corev1.PodTemplateSpec) bool
- type BaseDashboardClient
- type CRDType
- type FakeRayDashboardClient
- func (r *FakeRayDashboardClient) GetDeployments(_ context.Context) (string, error)
- func (r *FakeRayDashboardClient) GetJobInfo(ctx context.Context, jobId string) (*RayJobInfo, error)
- func (r *FakeRayDashboardClient) GetMultiApplicationStatus(_ context.Context) (map[string]*ServeApplicationStatus, error)
- func (r *FakeRayDashboardClient) GetServeDetails(_ context.Context) (*ServeDetails, error)
- func (r *FakeRayDashboardClient) GetSingleApplicationStatus(_ context.Context) (*ServeApplicationStatus, error)
- func (r *FakeRayDashboardClient) InitClient(url string)
- func (r *FakeRayDashboardClient) SetMultiApplicationStatuses(statuses map[string]*ServeApplicationStatus)
- func (r *FakeRayDashboardClient) SetSingleApplicationStatus(status ServeApplicationStatus)
- func (r *FakeRayDashboardClient) StopJob(_ context.Context, jobName string, log *logr.Logger) (err error)
- func (r *FakeRayDashboardClient) SubmitJob(_ context.Context, rayJob *rayv1.RayJob, log *logr.Logger) (jobId string, err error)
- func (r *FakeRayDashboardClient) UpdateDeployments(_ context.Context, configJson []byte, serveConfigType RayServeConfigType) error
- type FakeRayHttpProxyClient
- type RayActorOptionSpec
- type RayDashboardClient
- func (r *RayDashboardClient) ConvertServeDetailsToApplicationStatuses(serveDetails *ServeDetails) (map[string]*ServeApplicationStatus, error)
- func (r *RayDashboardClient) GetDeployments(ctx context.Context) (string, error)
- func (r *RayDashboardClient) GetJobInfo(ctx context.Context, jobId string) (*RayJobInfo, error)
- func (r *RayDashboardClient) GetMultiApplicationStatus(ctx context.Context) (map[string]*ServeApplicationStatus, error)
- func (r *RayDashboardClient) GetServeDetails(ctx context.Context) (*ServeDetails, error)
- func (r *RayDashboardClient) GetSingleApplicationStatus(ctx context.Context) (*ServeApplicationStatus, error)
- func (r *RayDashboardClient) InitClient(url string)
- func (r *RayDashboardClient) StopJob(ctx context.Context, jobName string, log *logr.Logger) (err error)
- func (r *RayDashboardClient) SubmitJob(ctx context.Context, rayJob *rayv1.RayJob, log *logr.Logger) (jobId string, err error)
- func (r *RayDashboardClient) UpdateDeployments(ctx context.Context, configJson []byte, serveConfigType RayServeConfigType) error
- type RayDashboardClientInterface
- type RayHttpProxyClient
- type RayHttpProxyClientInterface
- type RayJobInfo
- type RayJobRequest
- type RayJobResponse
- type RayJobStopResponse
- type RayServeConfigType
- type ServeAppStatusInfoV1
- type ServeApplicationDetails
- type ServeApplicationStatus
- type ServeConfigSpec
- type ServeDeploymentDetails
- type ServeDeploymentStatus
- type ServeDetails
- type ServeSingleApplicationStatusV1
- type ServingClusterDeployments
Constants ¶
const ( RayClusterSuffix = "-raycluster-" DashboardName = "dashboard" ServeName = "serve" ClusterDomainEnvKey = "CLUSTER_DOMAIN" DefaultDomainName = "cluster.local" )
Variables ¶
var ( // Single-application URL paths DeployPath = "/api/serve/deployments/" StatusPath = "/api/serve/deployments/status" // Multi-application URL paths ServeDetailsPath = "/api/serve/applications/" DeployPathV2 = "/api/serve/applications/" // Job URL paths JobPath = "/api/jobs/" )
var GetRayDashboardClientFunc = GetRayDashboardClient
GetRayDashboardClientFunc Used for unit tests.
var GetRayHttpProxyClientFunc = GetRayHttpProxyClient
GetRayHttpProxyClientFunc Used for unit tests.
Functions ¶
func CalculateAvailableReplicas ¶
CalculateAvailableReplicas calculates available worker replicas at the cluster level A worker is available if its Pod is running
func CalculateDesiredReplicas ¶
func CalculateDesiredReplicas(cluster *rayv1.RayCluster) int32
CalculateDesiredReplicas calculate desired worker replicas at the cluster level
func CalculateDesiredResources ¶
func CalculateDesiredResources(cluster *rayv1.RayCluster) corev1.ResourceList
func CalculateMaxReplicas ¶
func CalculateMaxReplicas(cluster *rayv1.RayCluster) int32
CalculateMaxReplicas calculates max worker replicas at the cluster level
func CalculateMinReplicas ¶
func CalculateMinReplicas(cluster *rayv1.RayCluster) int32
CalculateMinReplicas calculates min worker replicas at the cluster level
func CalculateMinResources ¶
func CalculateMinResources(cluster *rayv1.RayCluster) corev1.ResourceList
func CheckAllPodsRunning ¶ added in v0.6.0
CheckAllPodsRunning check if all pod in a list is running
func CheckLabel ¶
CheckLabel makes sure the label value does not start with a punctuation and the total length is < 63 char
func CheckName ¶
CheckName makes sure the name does not start with a numeric value and the total length is < 63 char
func CompareJsonStruct ¶
func CompareJsonStruct(objA interface{}, objB interface{}) bool
CompareJsonStruct This is a way to better compare if two objects are the same when they are json/yaml structs. reflect.DeepEqual will fail in some cases.
func ExtractRayIPFromFQDN ¶
ExtractRayIPFromFQDN extracts the head service name (i.e., RAY_IP, deprecated) from a fully qualified domain name (FQDN). This function is provided for backward compatibility purposes only.
func FetchHeadServiceURL ¶ added in v0.6.0
func FetchHeadServiceURL(ctx context.Context, log *logr.Logger, cli client.Client, rayCluster *rayv1.RayCluster, defaultPortName string) (string, error)
FetchHeadServiceURL fetches the URL that consists of the FQDN for the RayCluster's head service and the port with the given port name (defaultPortName).
func FilterContainerByName ¶
func FindContainerPort ¶ added in v0.6.0
FindContainerPort searches for a specific port $portName in the container. If the port is found in the container, the corresponding port is returned. If the port is not found, the $defaultPort is returned instead.
func FormatInt32 ¶
FormatInt returns the string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z' for digit values >= 10.
func GenerateFQDNServiceName ¶
func GenerateFQDNServiceName(cluster rayv1.RayCluster, namespace string) string
GenerateFQDNServiceName generates a Fully Qualified Domain Name.
func GenerateHeadServiceName ¶ added in v1.0.0
func GenerateHeadServiceName(crdType CRDType, clusterSpec rayv1.RayClusterSpec, ownerName string) (string, error)
GenerateHeadServiceName generates a Ray head service name. Note that there are two types of head services:
(1) For RayCluster: If `HeadService.Name` in the cluster spec is not empty, it will be used as the head service name. Otherwise, the name is generated based on the RayCluster CR's name. (2) For RayService: It's important to note that the RayService CR not only possesses a head service owned by its RayCluster CR but also maintains a separate head service for itself to facilitate zero-downtime upgrades. The name of the head service owned by the RayService CR is generated based on the RayService CR's name.
@param crdType: The type of the CRD that owns the head service. @param clusterSpec: `RayClusterSpec` @param ownerName: The name of the CR that owns the head service.
func GenerateIdentifier ¶
func GenerateIdentifier(clusterName string, nodeType rayv1.RayNodeType) string
GenerateIdentifier generates identifier of same group pods
func GenerateIngressName ¶
GenerateIngressName generates an ingress name from cluster name
func GenerateJsonHash ¶
Json-serializes obj and returns its hash string
func GenerateRayClusterName ¶
GenerateRayClusterName generates a ray cluster name from ray service name
func GenerateRayJobId ¶
GenerateRayJobId generates a ray job id for submission
func GenerateRouteName ¶ added in v1.0.0
GenerateRouteName generates an ingress name from cluster name
func GenerateServeServiceLabel ¶
GenerateServeServiceLabel generates label value for serve service selector.
func GenerateServeServiceName ¶
GenerateServeServiceName generates name for serve service.
func GetClusterDomainName ¶
func GetClusterDomainName() string
GetClusterDomainName returns cluster's domain name
func GetHeadGroupServiceAccountName ¶
func GetHeadGroupServiceAccountName(cluster *rayv1.RayCluster) string
GetHeadGroupServiceAccountName returns the head group service account if it exists. Otherwise, it returns the name of the cluster itself.
func GetNamespace ¶
func GetNamespace(metaData metav1.ObjectMeta) string
GetNamespace return namespace
func GetWorkerGroupDesiredReplicas ¶ added in v1.0.0
func GetWorkerGroupDesiredReplicas(workerGroupSpec rayv1.WorkerGroupSpec) int32
func IsRunningAndReady ¶
IsRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady.
func PodNotMatchingTemplate ¶
func PodNotMatchingTemplate(pod corev1.Pod, template corev1.PodTemplateSpec) bool
Types ¶
type BaseDashboardClient ¶ added in v0.6.0
type BaseDashboardClient struct {
// contains filtered or unexported fields
}
func (*BaseDashboardClient) ConvertServeConfigV1 ¶ added in v0.6.0
func (r *BaseDashboardClient) ConvertServeConfigV1(configV1Spec rayv1.ServeDeploymentGraphSpec) ServingClusterDeployments
type CRDType ¶ added in v1.0.0
type CRDType string
TODO (kevin85421): Define CRDType here rather than constant.go to avoid circular dependency.
type FakeRayDashboardClient ¶
type FakeRayDashboardClient struct { BaseDashboardClient GetJobInfoMock atomic.Pointer[func(context.Context, string) (*RayJobInfo, error)] // contains filtered or unexported fields }
func (*FakeRayDashboardClient) GetDeployments ¶
func (r *FakeRayDashboardClient) GetDeployments(_ context.Context) (string, error)
func (*FakeRayDashboardClient) GetJobInfo ¶
func (r *FakeRayDashboardClient) GetJobInfo(ctx context.Context, jobId string) (*RayJobInfo, error)
func (*FakeRayDashboardClient) GetMultiApplicationStatus ¶ added in v0.6.0
func (r *FakeRayDashboardClient) GetMultiApplicationStatus(_ context.Context) (map[string]*ServeApplicationStatus, error)
func (*FakeRayDashboardClient) GetServeDetails ¶ added in v0.6.0
func (r *FakeRayDashboardClient) GetServeDetails(_ context.Context) (*ServeDetails, error)
func (*FakeRayDashboardClient) GetSingleApplicationStatus ¶ added in v0.6.0
func (r *FakeRayDashboardClient) GetSingleApplicationStatus(_ context.Context) (*ServeApplicationStatus, error)
func (*FakeRayDashboardClient) InitClient ¶
func (r *FakeRayDashboardClient) InitClient(url string)
func (*FakeRayDashboardClient) SetMultiApplicationStatuses ¶ added in v0.6.0
func (r *FakeRayDashboardClient) SetMultiApplicationStatuses(statuses map[string]*ServeApplicationStatus)
func (*FakeRayDashboardClient) SetSingleApplicationStatus ¶ added in v0.6.0
func (r *FakeRayDashboardClient) SetSingleApplicationStatus(status ServeApplicationStatus)
func (*FakeRayDashboardClient) UpdateDeployments ¶
func (r *FakeRayDashboardClient) UpdateDeployments(_ context.Context, configJson []byte, serveConfigType RayServeConfigType) error
type FakeRayHttpProxyClient ¶
type FakeRayHttpProxyClient struct {
// contains filtered or unexported fields
}
func (*FakeRayHttpProxyClient) CheckHealth ¶
func (r *FakeRayHttpProxyClient) CheckHealth() error
func (*FakeRayHttpProxyClient) InitClient ¶
func (r *FakeRayHttpProxyClient) InitClient()
func (*FakeRayHttpProxyClient) SetHostIp ¶
func (r *FakeRayHttpProxyClient) SetHostIp(hostIp string, port int)
type RayActorOptionSpec ¶
type RayActorOptionSpec struct { RuntimeEnv map[string]interface{} `json:"runtime_env,omitempty"` NumCpus *float64 `json:"num_cpus,omitempty"` NumGpus *float64 `json:"num_gpus,omitempty"` Memory *uint64 `json:"memory,omitempty"` ObjectStoreMemory *uint64 `json:"object_store_memory,omitempty"` Resources map[string]interface{} `json:"resources,omitempty"` AcceleratorType string `json:"accelerator_type,omitempty"` }
RayActorOptionSpec defines the desired state of RayActor, used by Ray Dashboard.
type RayDashboardClient ¶
type RayDashboardClient struct {
BaseDashboardClient
}
func (*RayDashboardClient) ConvertServeDetailsToApplicationStatuses ¶ added in v0.6.0
func (r *RayDashboardClient) ConvertServeDetailsToApplicationStatuses(serveDetails *ServeDetails) (map[string]*ServeApplicationStatus, error)
func (*RayDashboardClient) GetDeployments ¶
func (r *RayDashboardClient) GetDeployments(ctx context.Context) (string, error)
GetDeployments get the current deployments in the Ray cluster.
func (*RayDashboardClient) GetJobInfo ¶
func (r *RayDashboardClient) GetJobInfo(ctx context.Context, jobId string) (*RayJobInfo, error)
func (*RayDashboardClient) GetMultiApplicationStatus ¶ added in v0.6.0
func (r *RayDashboardClient) GetMultiApplicationStatus(ctx context.Context) (map[string]*ServeApplicationStatus, error)
func (*RayDashboardClient) GetServeDetails ¶ added in v0.6.0
func (r *RayDashboardClient) GetServeDetails(ctx context.Context) (*ServeDetails, error)
GetServeDetails gets details on all live applications on the Ray cluster.
func (*RayDashboardClient) GetSingleApplicationStatus ¶ added in v0.6.0
func (r *RayDashboardClient) GetSingleApplicationStatus(ctx context.Context) (*ServeApplicationStatus, error)
GetDeploymentsStatus get the current deployment statuses in the Ray cluster.
func (*RayDashboardClient) InitClient ¶
func (r *RayDashboardClient) InitClient(url string)
func (*RayDashboardClient) UpdateDeployments ¶
func (r *RayDashboardClient) UpdateDeployments(ctx context.Context, configJson []byte, serveConfigType RayServeConfigType) error
UpdateDeployments update the deployments in the Ray cluster.
type RayDashboardClientInterface ¶
type RayDashboardClientInterface interface { InitClient(url string) GetDeployments(context.Context) (string, error) UpdateDeployments(ctx context.Context, configJson []byte, serveConfigType RayServeConfigType) error // V1/single-app Rest API GetSingleApplicationStatus(context.Context) (*ServeApplicationStatus, error) // V2/multi-app Rest API GetServeDetails(ctx context.Context) (*ServeDetails, error) GetMultiApplicationStatus(context.Context) (map[string]*ServeApplicationStatus, error) ConvertServeConfigV1(rayv1.ServeDeploymentGraphSpec) ServingClusterDeployments GetJobInfo(ctx context.Context, jobId string) (*RayJobInfo, error) SubmitJob(ctx context.Context, rayJob *rayv1.RayJob, log *logr.Logger) (jobId string, err error) StopJob(ctx context.Context, jobName string, log *logr.Logger) (err error) }
func GetRayDashboardClient ¶
func GetRayDashboardClient() RayDashboardClientInterface
type RayHttpProxyClient ¶
type RayHttpProxyClient struct {
// contains filtered or unexported fields
}
func (*RayHttpProxyClient) CheckHealth ¶
func (r *RayHttpProxyClient) CheckHealth() error
func (*RayHttpProxyClient) InitClient ¶
func (r *RayHttpProxyClient) InitClient()
func (*RayHttpProxyClient) SetHostIp ¶
func (r *RayHttpProxyClient) SetHostIp(hostIp string, port int)
type RayHttpProxyClientInterface ¶
type RayHttpProxyClientInterface interface { InitClient() CheckHealth() error SetHostIp(hostIp string, port int) }
func GetFakeRayHttpProxyClient ¶
func GetFakeRayHttpProxyClient() RayHttpProxyClientInterface
func GetRayHttpProxyClient ¶
func GetRayHttpProxyClient() RayHttpProxyClientInterface
type RayJobInfo ¶
type RayJobInfo struct { JobStatus rayv1.JobStatus `json:"status,omitempty"` Entrypoint string `json:"entrypoint,omitempty"` Message string `json:"message,omitempty"` ErrorType *string `json:"error_type,omitempty"` StartTime int64 `json:"start_time,omitempty"` EndTime int64 `json:"end_time,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
RayJobInfo is the response of "ray job status" api. Reference to https://docs.ray.io/en/latest/cluster/jobs-package-ref.html#jobinfo.
type RayJobRequest ¶
type RayJobRequest struct { Entrypoint string `json:"entrypoint"` JobId string `json:"job_id,omitempty"` RuntimeEnv map[string]interface{} `json:"runtime_env,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` }
RayJobRequest is the request body to submit. Reference to https://docs.ray.io/en/latest/cluster/jobs-package-ref.html#jobsubmissionclient.
func ConvertRayJobToReq ¶
func ConvertRayJobToReq(rayJob *rayv1.RayJob) (*RayJobRequest, error)
type RayJobResponse ¶
type RayJobResponse struct {
JobId string `json:"job_id"`
}
type RayJobStopResponse ¶
type RayJobStopResponse struct {
Stopped bool `json:"stopped"`
}
type RayServeConfigType ¶ added in v0.6.0
type RayServeConfigType string
Defines which Ray Serve config schema is used for `serveConfigV2`; can be SINGLE_APP or MULTI_APP. Please see the Ray Serve docs https://docs.ray.io/en/latest/serve/api/doc/ray.serve.schema.ServeApplicationSchema.html and https://docs.ray.io/en/latest/serve/api/doc/ray.serve.schema.ServeDeploySchema.html for the single-application schema and multi-application schema, respectively.
const ( MULTI_APP RayServeConfigType = "MULTI_APP" SINGLE_APP RayServeConfigType = "SINGLE_APP" )
type ServeAppStatusInfoV1 ¶ added in v0.6.0
type ServeAppStatusInfoV1 struct { Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` }
V1 Serve API Response format
type ServeApplicationDetails ¶ added in v0.6.0
type ServeApplicationDetails struct { ServeApplicationStatus RoutePrefix string `json:"route_prefix,omitempty"` DocsPath string `json:"docs_path,omitempty"` Deployments map[string]ServeDeploymentDetails `json:"deployments"` }
type ServeApplicationStatus ¶ added in v0.6.0
type ServeApplicationStatus struct { Name string `json:"name,omitempty"` Status string `json:"status"` Message string `json:"message,omitempty"` Deployments map[string]ServeDeploymentStatus `json:"deployments"` }
Describes the status of an application
type ServeConfigSpec ¶
type ServeConfigSpec struct { Name string `json:"name"` NumReplicas *int32 `json:"num_replicas,omitempty"` RoutePrefix string `json:"route_prefix,omitempty"` MaxConcurrentQueries *int32 `json:"max_concurrent_queries,omitempty"` UserConfig map[string]interface{} `json:"user_config,omitempty"` AutoscalingConfig map[string]interface{} `json:"autoscaling_config,omitempty"` GracefulShutdownWaitLoopS *int32 `json:"graceful_shutdown_wait_loop_s,omitempty"` GracefulShutdownTimeoutS *int32 `json:"graceful_shutdown_timeout_s,omitempty"` HealthCheckPeriodS *int32 `json:"health_check_period_s,omitempty"` HealthCheckTimeoutS *int32 `json:"health_check_timeout_s,omitempty"` RayActorOptions RayActorOptionSpec `json:"ray_actor_options,omitempty"` }
ServeConfigSpec defines the (single-application) desired state of RayService, used by Ray Dashboard. Serve schema details: https://docs.ray.io/en/latest/serve/api/doc/ray.serve.schema.ServeApplicationSchema.html
type ServeDeploymentDetails ¶ added in v0.6.0
type ServeDeploymentDetails struct { ServeDeploymentStatus RoutePrefix string `json:"route_prefix,omitempty"` }
V2 Serve API Response format. These extend the ServeDeploymentStatus and ServeApplicationStatus structs, but contain more information such as route prefix because the V2/multi-app GET API fetchs general metadata, not just statuses.
type ServeDeploymentStatus ¶ added in v0.6.0
type ServeDeploymentStatus struct { Name string `json:"name,omitempty"` Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` }
ServeDeploymentStatus and ServeApplicationStatus describe the format of status(es) that will be returned by GetSingleApplicationStatus and GetMultiApplicationStatus methods of the dashboard client Describes the status of a deployment
type ServeDetails ¶ added in v0.6.0
type ServeDetails struct { Applications map[string]ServeApplicationDetails `json:"applications"` DeployMode string `json:"deploy_mode,omitempty"` }
type ServeSingleApplicationStatusV1 ¶ added in v0.6.0
type ServeSingleApplicationStatusV1 struct { ApplicationStatus ServeAppStatusInfoV1 `json:"app_status,omitempty"` DeploymentStatuses []ServeDeploymentStatus `json:"deployment_statuses,omitempty"` }
type ServingClusterDeployments ¶
type ServingClusterDeployments struct { ImportPath string `json:"import_path"` RuntimeEnv map[string]interface{} `json:"runtime_env,omitempty"` Deployments []ServeConfigSpec `json:"deployments,omitempty"` Port int `json:"port,omitempty"` }
ServingClusterDeployments defines the request sent to the dashboard api server. See https://docs.ray.io/en/master/_modules/ray/serve/schema.html#ServeApplicationSchema for more details.