Skip to content

Commit

Permalink
[local-preview] Run gitpod-telemetry during exit
Browse files Browse the repository at this point in the history
While #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 <[email protected]>
  • Loading branch information
Pothulapati committed Jul 8, 2022
1 parent c719aa9 commit f3ccd03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions install/preview/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -146,11 +140,24 @@ run_telemetry(){
kubectl create job gitpod-telemetry-init --from=cronjob/gitpod-telemetry
}

run_telemetry 2>&1 &
run_exit_telemetry(){

sleep 100
# 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 \
exec /bin/k3s server --disable traefik \
--node-label gitpod.io/workload_meta=true \
--node-label gitpod.io/workload_ide=true \
--node-label gitpod.io/workload_workspace_services=true \
--node-label gitpod.io/workload_workspace_regular=true \
--node-label gitpod.io/workload_workspace_headless=true
--node-label gitpod.io/workload_workspace_headless=true || true
2 changes: 1 addition & 1 deletion install/preview/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ COPY --from=prettylog /app/prettylog /prettylog

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/tini", "--", "/entrypoint.sh" ]
ENTRYPOINT [ "/entrypoint.sh" ]

0 comments on commit f3ccd03

Please sign in to comment.