Skip to content

Commit

Permalink
Set autoscaler imagePullPolicy to IfNotPresent. Provide override. (ra…
Browse files Browse the repository at this point in the history
…y-project#297)

This PR exposes the autoscaler container pull policy in the Ray CRD for testing purposes.
  • Loading branch information
DmitriGekhtman authored Jun 8, 2022
1 parent ec4bf83 commit 5f6b21a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
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")
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,
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

0 comments on commit 5f6b21a

Please sign in to comment.