mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
In cluster selector mode, the deleting a CR should stop a job. This PR provides an initial implementation for this behavior. Co-authored-by: huyuanzhe <[email protected]>
94 lines
2.9 KiB
Go
94 lines
2.9 KiB
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/go-logr/logr"
|
|
"k8s.io/apimachinery/pkg/util/yaml"
|
|
|
|
rayv1alpha1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1"
|
|
)
|
|
|
|
type FakeRayDashboardClient struct {
|
|
client http.Client
|
|
dashboardURL string
|
|
serveStatuses ServeDeploymentStatuses
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) InitClient(url string) {
|
|
r.client = http.Client{}
|
|
r.dashboardURL = "http://" + url
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) GetDeployments() (string, error) {
|
|
panic("Fake GetDeployments not implemented")
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) UpdateDeployments(specs rayv1alpha1.ServeDeploymentGraphSpec) error {
|
|
fmt.Print("UpdateDeployments fake succeeds.")
|
|
return nil
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) GetDeploymentsStatus() (*ServeDeploymentStatuses, error) {
|
|
return &r.serveStatuses, nil
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) ConvertServeConfig(specs []rayv1alpha1.ServeConfigSpec) []ServeConfigSpec {
|
|
serveConfigToSend := make([]ServeConfigSpec, len(specs))
|
|
|
|
for i, config := range specs {
|
|
userConfig := make(map[string]interface{})
|
|
_ = yaml.Unmarshal([]byte(config.UserConfig), &userConfig)
|
|
|
|
autoscalingConfig := make(map[string]interface{})
|
|
_ = yaml.Unmarshal([]byte(config.AutoscalingConfig), &autoscalingConfig)
|
|
|
|
runtimeEnv := make(map[string]interface{})
|
|
_ = yaml.Unmarshal([]byte(config.RayActorOptions.RuntimeEnv), &runtimeEnv)
|
|
|
|
resources := make(map[string]interface{})
|
|
_ = yaml.Unmarshal([]byte(config.RayActorOptions.Resources), &resources)
|
|
|
|
serveConfigToSend[i] = ServeConfigSpec{
|
|
Name: config.Name,
|
|
NumReplicas: config.NumReplicas,
|
|
RoutePrefix: config.RoutePrefix,
|
|
MaxConcurrentQueries: config.MaxConcurrentQueries,
|
|
UserConfig: userConfig,
|
|
AutoscalingConfig: autoscalingConfig,
|
|
GracefulShutdownWaitLoopS: config.GracefulShutdownWaitLoopS,
|
|
GracefulShutdownTimeoutS: config.GracefulShutdownTimeoutS,
|
|
HealthCheckPeriodS: config.HealthCheckPeriodS,
|
|
HealthCheckTimeoutS: config.GracefulShutdownTimeoutS,
|
|
RayActorOptions: RayActorOptionSpec{
|
|
RuntimeEnv: runtimeEnv,
|
|
NumCpus: config.RayActorOptions.NumCpus,
|
|
NumGpus: config.RayActorOptions.NumGpus,
|
|
Memory: config.RayActorOptions.Memory,
|
|
ObjectStoreMemory: config.RayActorOptions.ObjectStoreMemory,
|
|
Resources: resources,
|
|
AcceleratorType: config.RayActorOptions.AcceleratorType,
|
|
},
|
|
}
|
|
}
|
|
|
|
return serveConfigToSend
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) SetServeStatus(status ServeDeploymentStatuses) {
|
|
r.serveStatuses = status
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) GetJobInfo(jobId string) (*RayJobInfo, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) SubmitJob(rayJob *rayv1alpha1.RayJob, log *logr.Logger) (jobId string, err error) {
|
|
return "", nil
|
|
}
|
|
|
|
func (r *FakeRayDashboardClient) StopJob(jobName string, log *logr.Logger) (err error) {
|
|
return nil
|
|
}
|