Skip to content

Commit

Permalink
[preview] run the telemetry job right after gitpod is ready
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Pothulapati authored and roboquat committed Jul 5, 2022
1 parent d50859a commit 79f7312
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions install/preview/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 79f7312

Please sign in to comment.