Skip to content

Commit 669c002

Browse files
committed
use a config option instead
Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent 0182d4e commit 669c002

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

components/installation-telemetry/cmd/send.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ var sendCmd = &cobra.Command{
4545
return fmt.Errorf("GITPOD_INSTALLATION_VERSION envvar not set")
4646
}
4747

48+
platform := os.Getenv("GITPOD_INSTALLATION_PLATFORM")
49+
if platform == "" {
50+
return fmt.Errorf("GITPOD_INSTALLATION_PLATFORM envvar not set")
51+
}
52+
4853
client, err := analytics.NewWithConfig(segmentIOToken, analytics.Config{})
4954
defer func() {
5055
err = client.Close()
@@ -54,12 +59,8 @@ var sendCmd = &cobra.Command{
5459
Set("version", versionId).
5560
Set("totalUsers", data.TotalUsers).
5661
Set("totalWorkspaces", data.TotalWorkspaces).
57-
Set("totalInstances", data.TotalInstances)
58-
59-
platform := os.Getenv("GITPOD_INSTALLATION_PLATFORM")
60-
if platform != "" {
61-
properties.Set("platform", platform)
62-
}
62+
Set("totalInstances", data.TotalInstances).
63+
Set("platform", platform)
6364

6465
if data.InstallationAdmin.Settings.SendCustomerID {
6566
properties.Set("customerID", data.CustomerID)

install/installer/pkg/components/gitpod/cronjob.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/gitpod-io/gitpod/installer/pkg/common"
1111
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
12+
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
1213
batchv1 "k8s.io/api/batch/v1"
1314
v1 "k8s.io/api/core/v1"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -21,6 +22,14 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
2122
return []runtime.Object{}, nil
2223
}
2324

25+
platformTelemetryData := "unknown"
26+
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
27+
if cfg.Telemetry != nil && cfg.Telemetry.Data.Platform != "" {
28+
platformTelemetryData = cfg.Telemetry.Data.Platform
29+
}
30+
return nil
31+
})
32+
2433
installationTelemetryComponent := fmt.Sprintf("%s-telemetry", Component)
2534

2635
objectMeta := metav1.ObjectMeta{
@@ -65,7 +74,7 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) {
6574
},
6675
{
6776
Name: "GITPOD_INSTALLATION_PLATFORM",
68-
Value: "installer",
77+
Value: platformTelemetryData,
6978
},
7079
{
7180
Name: "SERVER_URL",

install/installer/pkg/config/v1/experimental/experimental.go

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ type Config struct {
2121
WebApp *WebAppConfig `json:"webapp,omitempty"`
2222
IDE *IDEConfig `json:"ide,omitempty"`
2323
Common *CommonConfig `json:"common,omitempty"`
24+
Telemetry *TelemetryConfig `json:"telemetry,omitempty"`
25+
}
26+
27+
type TelemetryConfig struct {
28+
Data struct {
29+
Platform string `json:"platform"`
30+
} `json:"data"`
2431
}
2532

2633
type CommonConfig struct {

install/kots/manifests/gitpod-installer-job.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ spec:
273273
fi
274274
fi
275275
276+
echo "Gitpod: Update platform telemetry value"
277+
yq eval-all --inplace '.experimental.telemetry.data.platform = "{{repl Distribution }}"' "${CONFIG_FILE}"
278+
276279
echo "Gitpod: Patch Gitpod config"
277280
base64 -d "${CONFIG_PATCH_FILE}" > /tmp/patch.yaml
278281
config_patch=$(cat /tmp/patch.yaml)
@@ -303,11 +306,6 @@ spec:
303306
'del(select(.kind == "StatefulSet" and .metadata.name == "openvsx-proxy").status)' \
304307
"${GITPOD_OBJECTS}/templates/gitpod.yaml"
305308
306-
echo "Gitpod: Update GITPOD_INSTALLATION_PLATFORM telemetry value"
307-
yq eval-all --inplace \
308-
'(select(.kind == "CronJob" and .metadata.name == "gitpod-telemetry") | (.spec.jobTemplate.spec.template.spec.containers[0].env[] | select(.name=="GITPOD_INSTALLATION_PLATFORM")).value |= "repl{{ Distribution }}"' \
309-
"${GITPOD_OBJECTS}/templates/gitpod.yaml"
310-
311309
if [ '{{repl ConfigOptionEquals "reg_incluster" "1" }}' = "true" ];
312310
then
313311
echo "Gitpod: Add the local registry secret to the in-cluster registry secret"

install/preview/entrypoint.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ yq e -i '.customCACert.kind = "secret"' config.yaml
100100
yq e -i '.observability.logLevel = "debug"' config.yaml
101101
yq e -i '.workspace.runtime.containerdSocket = "/run/k3s/containerd/containerd.sock"' config.yaml
102102
yq e -i '.workspace.runtime.containerdRuntimeDir = "/var/lib/rancher/k3s/agent/containerd/io.containerd.runtime.v2.task/k8s.io/"' config.yaml
103+
yq e -i '.experimental.telemetry.data.platform = "local-preview"' config.yaml
103104

104105
echo "extracting images to download ahead..."
105-
/gitpod-installer render --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt
106+
/gitpod-installer render --use-experimental-config --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt
106107
echo "downloading images..."
107108
while read -r image "$(cat /gitpod-images.txt)"; do
108109
# shellcheck disable=SC2154
@@ -124,8 +125,6 @@ yq eval-all -i ". as \$item ireduce ({}; . *+ \$item)" /var/lib/rancher/k3s/serv
124125
# update Statefulset's to use k3s's `local-path` storage class
125126
for f in /var/lib/rancher/k3s/server/manifests/gitpod/*StatefulSet*.yaml; do yq e -i '.spec.volumeClaimTemplates[0].spec.storageClassName="local-path"' "$f"; done
126127

127-
# set the GITPOD_INSTALLATION_PLATFORM
128-
yq eval-all -i '(.spec.jobTemplate.spec.template.spec.containers[0].env[] | select(.name=="GITPOD_INSTALLATION_PLATFORM")).value |= "local-preview"' /var/lib/rancher/k3s/server/manifests/gitpod/*_CronJob_gitpod-telemetry.yaml
129128

130129
# removing init container from ws-daemon (systemd and Ubuntu)
131130
yq eval-all -i 'del(.spec.template.spec.initContainers[0])' /var/lib/rancher/k3s/server/manifests/gitpod/*_DaemonSet_ws-daemon.yaml

0 commit comments

Comments
 (0)