From ff8cf8bd141db7df10b05c34b2241475d9be4648 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Fri, 8 Jul 2022 05:30:37 +0000 Subject: [PATCH] [local-preview] Run `gitpod-telemetry` during exit While https://github.com/gitpod-io/gitpod/pull/11077 adds a way to send telemetry once a `local-preview` instance is instantiated and is running, The user data is not very useful here as the user hasn't performed any actions, etc. This data is only useful right now to know that a new install has been performed. This PR updates the `local-preview` to also do the same whenever a exit signal is created, By doing this we also get the same data once a instance is being closed and hence giving use anonymous info on the usage. Signed-off-by: Tarun Pothulapati --- install/preview/entrypoint.sh | 21 +++++++++++++-------- install/preview/leeway.Dockerfile | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/install/preview/entrypoint.sh b/install/preview/entrypoint.sh index 78a70eef1d08df..998abe8d58af76 100755 --- a/install/preview/entrypoint.sh +++ b/install/preview/entrypoint.sh @@ -4,11 +4,6 @@ set -e -if [ "$1" != "logging" ]; then - $0 logging 2>&1 | /prettylog - exit -fi - # check for minimum requirements REQUIRED_MEM_KB=$((6 * 1024 * 1024)) total_mem_kb=$(awk '/MemTotal:/ {print $2}' /proc/meminfo) @@ -136,8 +131,7 @@ 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(){ +run_init_telemetry(){ # wait for the k3s cluster to be ready and Gitpod workloads are added sleep 100 # indefinitely wait for Gitpod pods to be ready @@ -146,7 +140,18 @@ run_telemetry(){ kubectl create job gitpod-telemetry-init --from=cronjob/gitpod-telemetry } -run_telemetry 2>&1 & +run_exit_telemetry(){ + # 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-exit --from=cronjob/gitpod-telemetry + # wait for the job to finish + sleep 30 +} + +trap 'run_exit_telemetry 2>&1' EXIT INT HUP + +run_init_telemetry 2>&1 & /bin/k3s server --disable traefik \ --node-label gitpod.io/workload_meta=true \ diff --git a/install/preview/leeway.Dockerfile b/install/preview/leeway.Dockerfile index c8c50fa840d59e..b7630650fd3ea2 100644 --- a/install/preview/leeway.Dockerfile +++ b/install/preview/leeway.Dockerfile @@ -26,4 +26,4 @@ COPY --from=prettylog /app/prettylog /prettylog COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT [ "/tini", "--", "/entrypoint.sh" ] +ENTRYPOINT [ "/entrypoint.sh" ]