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

Provide override for autoscaler image pull policy. #297

Merged
merged 4 commits into from
Jun 8, 2022
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
2 changes: 2 additions & 0 deletions ray-operator/apis/ray/v1alpha1/raycluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type AutoscalerOptions struct {
Resources *v1.ResourceRequirements `json:"resources,omitempty"`
// Image optionally overrides the autoscaler's container image. This override is for provided for autoscaler testing and development.
Image *string `json:"image,omitempty"`
// ImagePullPolicy optionally overrides the autoscaler container's image pull policy. This override is for provided for autoscaler testing and development.
ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"`
// IdleTimeoutSeconds is the number of seconds to wait before scaling down a worker pod which is not using Ray resources.
// Defaults to 300 (five minutes).
IdleTimeoutSeconds *int32 `json:"idleTimeoutSeconds,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions ray-operator/apis/ray/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions ray-operator/config/crd/bases/ray.io_rayclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ spec:
description: Image optionally overrides the autoscaler's container
image.
type: string
imagePullPolicy:
description: ImagePullPolicy optionally overrides the autoscaler
container's image pull policy.
type: string
resources:
description: Resources specifies resource requests and limits
for the autoscaler container.
Expand Down
3 changes: 3 additions & 0 deletions ray-operator/controllers/ray/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func mergeAutoscalerOverrides(autoscalerContainer *v1.Container, autoscalerOptio
if autoscalerOptions.Image != nil {
autoscalerContainer.Image = *autoscalerOptions.Image
}
if autoscalerOptions.ImagePullPolicy != nil {
autoscalerContainer.ImagePullPolicy = *autoscalerOptions.ImagePullPolicy
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions ray-operator/controllers/ray/common/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ func TestBuildPodWithAutoscalerOptions(t *testing.T) {
svcName := utils.GenerateServiceName(cluster.Name)

customAutoscalerImage := "custom-autoscaler-xxx"
customPullPolicy := v1.PullIfNotPresent
customTimeout := int32(100)
customUpscaling := "Aggressive"
customUpscaling := rayiov1alpha1.UpscalingMode("Aggressive")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is clean-up

customResources := v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("1"),
Expand All @@ -358,15 +359,17 @@ func TestBuildPodWithAutoscalerOptions(t *testing.T) {
}

cluster.Spec.AutoscalerOptions = &rayiov1alpha1.AutoscalerOptions{
UpscalingMode: (*rayiov1alpha1.UpscalingMode)(&customUpscaling),
UpscalingMode: &customUpscaling,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean-up

IdleTimeoutSeconds: &customTimeout,
Image: &customAutoscalerImage,
ImagePullPolicy: &customPullPolicy,
Resources: &customResources,
}
podTemplateSpec := DefaultHeadPodTemplate(*cluster, cluster.Spec.HeadGroupSpec, podName, svcName)
pod := BuildPod(podTemplateSpec, rayiov1alpha1.HeadNode, cluster.Spec.HeadGroupSpec.RayStartParams, svcName, &trueFlag)
expectedContainer := *autoscalerContainer.DeepCopy()
expectedContainer.Image = customAutoscalerImage
expectedContainer.ImagePullPolicy = customPullPolicy
expectedContainer.Resources = customResources
index := getAutoscalerContainerIndex(pod)
actualContainer := pod.Spec.Containers[index]
Expand Down