Skip to content

Commit 36076e5

Browse files
authored
[Cherry-pick][Telemetry] KubeRay version and CRD (#2024) (#2032)
1 parent c815076 commit 36076e5

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

docs/development/release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Manual testing can be time-consuming, and to relieve the workload, we plan to ad
6565
6666
* Merge a PR into the release branch updating Helm chart versions, Helm chart image tags, and kustomize manifest image tags. For `v0.5.0-rc0`, we did this in [PR #1001](https://github.com/ray-project/kuberay/pull/1001)
6767
68+
* Merge a PR into the release branch to update the `KUBERAY_VERSION` in `constant.go` for telemetry purposes.
69+
6870
* Release `rc0` images using the [release-image-build](https://github.com/ray-project/kuberay/actions/workflows/image-release.yaml) workflow on GitHub actions.
6971
You will be prompted for a commit reference and an image tag. The commit reference should be the SHA of the tip of the release branch. The image tag should be `vX.Y.Z-rc.0`.
7072

ray-operator/controllers/ray/common/pod.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,13 @@ func setContainerEnvVars(pod *corev1.Pod, rayNodeType rayv1.RayNodeType, rayStar
629629
usageEnv := corev1.EnvVar{Name: utils.RAY_USAGE_STATS_KUBERAY_IN_USE, Value: "1"}
630630
container.Env = append(container.Env, usageEnv)
631631
}
632+
if rayNodeType == rayv1.HeadNode {
633+
extraTagsEnv := corev1.EnvVar{
634+
Name: utils.RAY_USAGE_STATS_EXTRA_TAGS,
635+
Value: fmt.Sprintf("kuberay_version=%s;kuberay_crd=%s", utils.KUBERAY_VERSION, string(creatorCRDType)),
636+
}
637+
container.Env = append(container.Env, extraTagsEnv)
638+
}
632639
if !utils.EnvVarExists(utils.REDIS_PASSWORD, container.Env) {
633640
// setting the REDIS_PASSWORD env var from the params
634641
redisPasswordEnv := corev1.EnvVar{Name: utils.REDIS_PASSWORD}

ray-operator/controllers/ray/common/pod_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ func TestBuildPod(t *testing.T) {
316316
checkContainerEnv(t, rayContainer, utils.RAY_CLUSTER_NAME, fmt.Sprintf("metadata.labels['%s']", utils.RayClusterLabelKey))
317317
checkContainerEnv(t, rayContainer, utils.RAY_DASHBOARD_ENABLE_K8S_DISK_USAGE, "1")
318318
checkContainerEnv(t, rayContainer, utils.RAY_NODE_TYPE_NAME, fmt.Sprintf("metadata.labels['%s']", utils.RayNodeGroupLabelKey))
319+
checkContainerEnv(t, rayContainer, utils.RAY_USAGE_STATS_EXTRA_TAGS, fmt.Sprintf("kuberay_version=%s;kuberay_crd=%s", utils.KUBERAY_VERSION, utils.RayClusterCRD))
319320
headRayStartCommandEnv := getEnvVar(rayContainer, utils.KUBERAY_GEN_RAY_START_CMD)
320321
assert.True(t, strings.Contains(headRayStartCommandEnv.Value, "ray start"))
321322

ray-operator/controllers/ray/utils/constant.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const (
102102
RAY_GCS_SERVER_REQUEST_TIMEOUT_SECONDS = "RAY_gcs_server_request_timeout_seconds"
103103
RAY_SERVE_KV_TIMEOUT_S = "RAY_SERVE_KV_TIMEOUT_S"
104104
RAY_USAGE_STATS_KUBERAY_IN_USE = "RAY_USAGE_STATS_KUBERAY_IN_USE"
105+
RAY_USAGE_STATS_EXTRA_TAGS = "RAY_USAGE_STATS_EXTRA_TAGS"
105106
RAYCLUSTER_DEFAULT_REQUEUE_SECONDS_ENV = "RAYCLUSTER_DEFAULT_REQUEUE_SECONDS_ENV"
106107
RAYCLUSTER_DEFAULT_REQUEUE_SECONDS = 300
107108
KUBERAY_GEN_RAY_START_CMD = "KUBERAY_GEN_RAY_START_CMD"
@@ -167,6 +168,9 @@ const (
167168

168169
// RayNodeHeadGroupLabelValue is the value for the RayNodeGroupLabelKey label on a head node
169170
RayNodeHeadGroupLabelValue = "headgroup"
171+
172+
// Telemetry
173+
KUBERAY_VERSION = "nightly"
170174
)
171175

172176
type ServiceType string

ray-operator/controllers/ray/utils/util.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const (
3838
RayClusterCRD CRDType = "RayCluster"
3939
RayJobCRD CRDType = "RayJob"
4040
RayServiceCRD CRDType = "RayService"
41-
UnknownCRD CRDType = "Unknown"
4241
)
4342

4443
var crdMap = map[string]CRDType{
@@ -51,7 +50,7 @@ func GetCRDType(key string) CRDType {
5150
if crdType, exists := crdMap[key]; exists {
5251
return crdType
5352
}
54-
return UnknownCRD
53+
return RayClusterCRD
5554
}
5655

5756
// GetClusterDomainName returns cluster's domain name

ray-operator/main.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ import (
3737
)
3838

3939
var (
40-
_version_ = "0.2"
41-
_buildTime_ = ""
42-
_commitId_ = ""
43-
scheme = runtime.NewScheme()
44-
setupLog = ctrl.Log.WithName("setup")
40+
scheme = runtime.NewScheme()
41+
setupLog = ctrl.Log.WithName("setup")
4542
// TODO: include the kuberay version in the user-agent. E.g. ray-operator/v1.1.0
4643
userAgent = "kuberay-operator"
4744
)
@@ -57,7 +54,6 @@ func init() {
5754
}
5855

5956
func main() {
60-
var version bool
6157
var metricsAddr string
6258
var enableLeaderElection bool
6359
var leaderElectionNamespace string
@@ -70,7 +66,6 @@ func main() {
7066
var configFile string
7167

7268
// TODO: remove flag-based config once Configuration API graduates to v1.
73-
flag.BoolVar(&version, "version", false, "Show the version information.")
7469
flag.StringVar(&metricsAddr, "metrics-addr", configapi.DefaultMetricsAddr, "The address the metric endpoint binds to.")
7570
flag.StringVar(&probeAddr, "health-probe-bind-address", configapi.DefaultProbeAddr, "The address the probe endpoint binds to.")
7671
flag.BoolVar(&enableLeaderElection, "enable-leader-election", configapi.DefaultEnableLeaderElection,
@@ -100,12 +95,6 @@ func main() {
10095
}
10196
opts.BindFlags(flag.CommandLine)
10297
flag.Parse()
103-
if version {
104-
fmt.Printf("Version:\t%s\n", _version_)
105-
fmt.Printf("Commit ID:\t%s\n", _commitId_)
106-
fmt.Printf("Build time:\t%s\n", _buildTime_)
107-
os.Exit(0)
108-
}
10998

11099
var config configapi.Configuration
111100
if configFile != "" {
@@ -161,7 +150,6 @@ func main() {
161150
ctrl.SetLogger(k8szap.New(k8szap.UseFlagOptions(&opts)))
162151
}
163152

164-
setupLog.Info("the operator", "version:", os.Getenv("OPERATOR_VERSION"))
165153
if ray.ForcedClusterUpgrade {
166154
setupLog.Info("Feature flag forced-cluster-upgrade is enabled.")
167155
}

0 commit comments

Comments
 (0)