From 1661885efbf2a3f83aa94e61cef90aeee871c1ae Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Fri, 1 Jul 2022 10:52:22 +0000 Subject: [PATCH] [preview] run the telemetry job right after gitpod is ready This PR updates the `entry-point.sh` to run a parallel step that waits for the gitpod pods to be ready, and manually executes the cronjob once its necessary. This is necessary as our telemetry `cronjobs` are only ran daily in the midnight, and we can't expect this schedule to work for local previews as they are short lived. example data that we get: ``` client.Track(&analytics.Track{ UserId: "334c379a-afee-4882-ba44-fbd7dfc0a8b0", Event: "Installation telemetry", Properties: map[string]interface{}{ "customerID": "", "platform": "local-preview", "totalInstances": 0, "totalUsers": 0, "totalWorkspaces": 0, "version": "tar-preview-tel-init.4", }, }) ``` Signed-off-by: Tarun Pothulapati --- install/preview/entrypoint.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/install/preview/entrypoint.sh b/install/preview/entrypoint.sh index d62ae90e4ad87c..78a70eef1d08df 100755 --- a/install/preview/entrypoint.sh +++ b/install/preview/entrypoint.sh @@ -136,6 +136,18 @@ yq eval-all -i 'del(.spec.template.spec.initContainers[0])' /var/lib/rancher/k3s for f in /var/lib/rancher/k3s/server/manifests/gitpod/*.yaml; do (cat "$f"; echo) >> /var/lib/rancher/k3s/server/manifests/gitpod.yaml; done rm -rf /var/lib/rancher/k3s/server/manifests/gitpod +# waits for gitpod pods to be ready, and manually runs the `gitpod-telemetry` cronjob +run_telemetry(){ + # wait for the k3s cluster to be ready and Gitpod workloads are added + sleep 100 + # indefinitely wait for Gitpod pods to be ready + kubectl wait --timeout=-1s --for=condition=ready pod -l app=gitpod,component!=migrations + # manually tun the cronjob + kubectl create job gitpod-telemetry-init --from=cronjob/gitpod-telemetry +} + +run_telemetry 2>&1 & + /bin/k3s server --disable traefik \ --node-label gitpod.io/workload_meta=true \ --node-label gitpod.io/workload_ide=true \