Skip to content

Commit

Permalink
[Telemetry] Inject env identifying KubeRay. #562
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitri Gekhtman <[email protected]>

This change has the KubeRay operator inject an env var identifying a Ray container as having been deployed using KubeRay.
The purpose is to refine Ray usage stats collected by Ray's telemetry service (https://docs.ray.io/en/latest/cluster/usage-stats.html).

See ray-project/ray#28490
  • Loading branch information
DmitriGekhtman authored Sep 14, 2022
1 parent 4cd2013 commit 38ac168
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions ray-operator/controllers/ray/common/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
RAY_SERVE_KV_TIMEOUT_S = "RAY_SERVE_KV_TIMEOUT_S"
SERVE_DEPLOYMENT_HANDLE_IS_SYNC = "SERVE_DEPLOYMENT_HANDLE_IS_SYNC"
SERVE_CONTROLLER_PIN_ON_NODE = "RAY_INTERNAL_SERVE_CONTROLLER_PIN_ON_NODE"
RAY_USAGE_STATS_KUBERAY_IN_USE = "RAY_USAGE_STATS_KUBERAY_IN_USE"

// Ray core default configurations
DefaultRedisPassword = "5241590000000000"
Expand Down
4 changes: 4 additions & 0 deletions ray-operator/controllers/ray/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,10 @@ func setContainerEnvVars(pod *v1.Pod, rayContainerIndex int, rayNodeType rayiov1
addressEnv := v1.EnvVar{Name: RAY_ADDRESS, Value: rayAddress}
container.Env = append(container.Env, addressEnv)
}
if !envVarExists(RAY_USAGE_STATS_KUBERAY_IN_USE, container.Env) {
usageEnv := v1.EnvVar{Name: RAY_USAGE_STATS_KUBERAY_IN_USE, Value: "1"}
container.Env = append(container.Env, usageEnv)
}
if !envVarExists(REDIS_PASSWORD, container.Env) {
// setting the REDIS_PASSWORD env var from the params
port := v1.EnvVar{Name: REDIS_PASSWORD}
Expand Down
2 changes: 2 additions & 0 deletions ray-operator/controllers/ray/common/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ func TestBuildPod(t *testing.T) {

// Check RAY_ADDRESS env.
checkPodEnv(t, pod, RAY_ADDRESS, "127.0.0.1:6379")
// Check usage stats env.
checkPodEnv(t, pod, RAY_USAGE_STATS_KUBERAY_IN_USE, "1")

// Check labels.
actualResult := pod.Labels[RayClusterLabelKey]
Expand Down

0 comments on commit 38ac168

Please sign in to comment.