Skip to content

Commit a7dc039

Browse files
committed
[installer] add experimental flag for ide-metrics
1 parent 6d4e63a commit a7dc039

File tree

13 files changed

+146
-41
lines changed

13 files changed

+146
-41
lines changed

.werft/jobs/build/installer/installer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ EOF`);
167167

168168
private configureIDE(slice: string) {
169169
exec(`yq w -i ${this.options.installerConfigPath} experimental.ide.resolveLatest false`, { slice });
170+
exec(`yq w -i ${this.options.installerConfigPath} experimental.ide.ideMetrics.enabledErrorReporting true`, { slice });
170171
}
171172

172173
private configureObservability(slice: string) {

install/installer/cmd/testdata/render/aws-setup/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -3768,7 +3768,12 @@ data:
37683768
30
37693769
]
37703770
}
3771-
]
3771+
],
3772+
"errorReporting": {
3773+
"allowComponents": [
3774+
"supervisor-frontend"
3775+
]
3776+
}
37723777
},
37733778
"debug": false,
37743779
"pprof": {
@@ -7426,7 +7431,7 @@ spec:
74267431
template:
74277432
metadata:
74287433
annotations:
7429-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
7434+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
74307435
creationTimestamp: null
74317436
labels:
74327437
app: gitpod

install/installer/cmd/testdata/render/azure-setup/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,12 @@ data:
36863686
30
36873687
]
36883688
}
3689-
]
3689+
],
3690+
"errorReporting": {
3691+
"allowComponents": [
3692+
"supervisor-frontend"
3693+
]
3694+
}
36903695
},
36913696
"debug": false,
36923697
"pprof": {
@@ -7260,7 +7265,7 @@ spec:
72607265
template:
72617266
metadata:
72627267
annotations:
7263-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
7268+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
72647269
creationTimestamp: null
72657270
labels:
72667271
app: gitpod

install/installer/cmd/testdata/render/customization/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -4468,7 +4468,12 @@ data:
44684468
30
44694469
]
44704470
}
4471-
]
4471+
],
4472+
"errorReporting": {
4473+
"allowComponents": [
4474+
"supervisor-frontend"
4475+
]
4476+
}
44724477
},
44734478
"debug": false,
44744479
"pprof": {
@@ -8653,7 +8658,7 @@ spec:
86538658
metadata:
86548659
annotations:
86558660
gitpod.io: hello
8656-
gitpod.io/checksum_config: 7aca852c0c589f808186529f22f534f9db9fa4ae31546cedc307f7e26ec9c4cf
8661+
gitpod.io/checksum_config: 8beda82ff6c689641e3e3d74cfa333942daf49ba5617133a5c6ec21a44408f22
86578662
hello: world
86588663
creationTimestamp: null
86598664
labels:

install/installer/cmd/testdata/render/external-registry/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -3827,7 +3827,12 @@ data:
38273827
30
38283828
]
38293829
}
3830-
]
3830+
],
3831+
"errorReporting": {
3832+
"allowComponents": [
3833+
"supervisor-frontend"
3834+
]
3835+
}
38313836
},
38323837
"debug": false,
38333838
"pprof": {
@@ -7701,7 +7706,7 @@ spec:
77017706
template:
77027707
metadata:
77037708
annotations:
7704-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
7709+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
77057710
creationTimestamp: null
77067711
labels:
77077712
app: gitpod

install/installer/cmd/testdata/render/gcp-setup/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -3657,7 +3657,12 @@ data:
36573657
30
36583658
]
36593659
}
3660-
]
3660+
],
3661+
"errorReporting": {
3662+
"allowComponents": [
3663+
"supervisor-frontend"
3664+
]
3665+
}
36613666
},
36623667
"debug": false,
36633668
"pprof": {
@@ -7315,7 +7320,7 @@ spec:
73157320
template:
73167321
metadata:
73177322
annotations:
7318-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
7323+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
73197324
creationTimestamp: null
73207325
labels:
73217326
app: gitpod

install/installer/cmd/testdata/render/minimal/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -3993,7 +3993,12 @@ data:
39933993
30
39943994
]
39953995
}
3996-
]
3996+
],
3997+
"errorReporting": {
3998+
"allowComponents": [
3999+
"supervisor-frontend"
4000+
]
4001+
}
39974002
},
39984003
"debug": false,
39994004
"pprof": {
@@ -7981,7 +7986,7 @@ spec:
79817986
template:
79827987
metadata:
79837988
annotations:
7984-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
7989+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
79857990
creationTimestamp: null
79867991
labels:
79877992
app: gitpod

install/installer/cmd/testdata/render/statefulset-customization/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -4005,7 +4005,12 @@ data:
40054005
30
40064006
]
40074007
}
4008-
]
4008+
],
4009+
"errorReporting": {
4010+
"allowComponents": [
4011+
"supervisor-frontend"
4012+
]
4013+
}
40094014
},
40104015
"debug": false,
40114016
"pprof": {
@@ -7993,7 +7998,7 @@ spec:
79937998
template:
79947999
metadata:
79958000
annotations:
7996-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
8001+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
79978002
creationTimestamp: null
79988003
labels:
79998004
app: gitpod

install/installer/cmd/testdata/render/use-pod-security-policies/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -4326,7 +4326,12 @@ data:
43264326
30
43274327
]
43284328
}
4329-
]
4329+
],
4330+
"errorReporting": {
4331+
"allowComponents": [
4332+
"supervisor-frontend"
4333+
]
4334+
}
43304335
},
43314336
"debug": false,
43324337
"pprof": {
@@ -8425,7 +8430,7 @@ spec:
84258430
template:
84268431
metadata:
84278432
annotations:
8428-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
8433+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
84298434
creationTimestamp: null
84308435
labels:
84318436
app: gitpod

install/installer/cmd/testdata/render/workspace-requests-limits/output.golden

+7-2
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,12 @@ data:
39963996
30
39973997
]
39983998
}
3999-
]
3999+
],
4000+
"errorReporting": {
4001+
"allowComponents": [
4002+
"supervisor-frontend"
4003+
]
4004+
}
40004005
},
40014006
"debug": false,
40024007
"pprof": {
@@ -7984,7 +7989,7 @@ spec:
79847989
template:
79857990
metadata:
79867991
annotations:
7987-
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
7992+
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
79887993
creationTimestamp: null
79897994
labels:
79907995
app: gitpod

install/installer/pkg/components/ide-metrics/configmap.go

+7
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,19 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
109109
},
110110
}
111111

112+
errorReporting := config.ErrorReportingConfiguration{
113+
AllowComponents: []string{
114+
"supervisor-frontend",
115+
},
116+
}
117+
112118
cfg := config.ServiceConfiguration{
113119
Server: config.MetricsServerConfiguration{
114120
Port: ContainerPort,
115121
// RateLimits: , // TODO(pd) ratelimit
116122
CounterMetrics: counterMetrics,
117123
HistogramMetrics: histogramMetrics,
124+
ErrorReporting: errorReporting,
118125
},
119126
Prometheus: struct {
120127
Addr string `json:"addr"`

install/installer/pkg/components/ide-metrics/deployment.go

+65-20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package ide_metrics
77
import (
88
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
99
"github.com/gitpod-io/gitpod/installer/pkg/common"
10+
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
1011

1112
appsv1 "k8s.io/api/apps/v1"
1213
corev1 "k8s.io/api/core/v1"
@@ -25,6 +26,67 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
2526
return nil, err
2627
}
2728

29+
volumes := make([]corev1.Volume, 0)
30+
volumeMounts := make([]corev1.VolumeMount, 0)
31+
32+
volumes = append(volumes, corev1.Volume{
33+
Name: VolumeConfig,
34+
VolumeSource: corev1.VolumeSource{
35+
ConfigMap: &corev1.ConfigMapVolumeSource{
36+
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
37+
},
38+
},
39+
})
40+
41+
volumeMounts = append(volumeMounts, corev1.VolumeMount{
42+
Name: VolumeConfig,
43+
MountPath: "/config",
44+
ReadOnly: true,
45+
})
46+
47+
env := common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
48+
common.DefaultEnv(&ctx.Config),
49+
))
50+
51+
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
52+
if cfg.IDE != nil && cfg.IDE.IDEMetricsConfig != nil {
53+
if cfg.IDE.IDEMetricsConfig.EnabledErrorReporting {
54+
env = append(env, corev1.EnvVar{
55+
Name: "GITPOD_ENABLED_ERROR_REPORTING",
56+
Value: "true",
57+
})
58+
59+
if cfg.IDE.IDEMetricsConfig.GCPADCSecret != "" && cfg.IDE.IDEMetricsConfig.GCPProject != "" {
60+
volumes = append(volumes, corev1.Volume{
61+
Name: "gcp-adc-file",
62+
VolumeSource: corev1.VolumeSource{
63+
ConfigMap: &corev1.ConfigMapVolumeSource{
64+
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
65+
},
66+
},
67+
})
68+
69+
volumeMounts = append(volumeMounts, corev1.VolumeMount{
70+
Name: "gcp-adc-file",
71+
MountPath: "/gcp",
72+
ReadOnly: true,
73+
})
74+
75+
env = append(env, corev1.EnvVar{
76+
Name: "GOOGLE_PROJECT",
77+
Value: cfg.IDE.IDEMetricsConfig.GCPProject,
78+
})
79+
env = append(env, corev1.EnvVar{
80+
Name: "GOOGLE_APPLICATION_CREDENTIALS",
81+
Value: "/gcp/credentials.json",
82+
})
83+
}
84+
}
85+
86+
}
87+
return nil
88+
})
89+
2890
return []runtime.Object{
2991
&appsv1.Deployment{
3092
TypeMeta: common.TypeMetaDeployment,
@@ -74,16 +136,8 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
74136
SecurityContext: &corev1.SecurityContext{
75137
Privileged: pointer.Bool(false),
76138
},
77-
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
78-
common.DefaultEnv(&ctx.Config),
79-
)),
80-
VolumeMounts: []corev1.VolumeMount{
81-
{
82-
Name: VolumeConfig,
83-
MountPath: "/config",
84-
ReadOnly: true,
85-
},
86-
},
139+
Env: env,
140+
VolumeMounts: volumeMounts,
87141
ReadinessProbe: &corev1.Probe{
88142
ProbeHandler: corev1.ProbeHandler{
89143
TCPSocket: &corev1.TCPSocketAction{
@@ -97,16 +151,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
97151
},
98152
*common.KubeRBACProxyContainerWithConfig(ctx),
99153
},
100-
Volumes: []corev1.Volume{
101-
{
102-
Name: VolumeConfig,
103-
VolumeSource: corev1.VolumeSource{
104-
ConfigMap: &corev1.ConfigMapVolumeSource{
105-
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
106-
},
107-
},
108-
},
109-
},
154+
Volumes: volumes,
110155
},
111156
},
112157
},

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,22 @@ type WebAppWorkspaceClass struct {
255255

256256
type IDEConfig struct {
257257
// Disable resolution of latest images and use bundled latest versions instead
258-
ResolveLatest *bool `json:"resolveLatest,omitempty"`
259-
IDEProxyConfig *IDEProxyConfig `json:"ideProxy,omitempty"`
260-
VSXProxyConfig *VSXProxyConfig `json:"openvsxProxy,omitempty"`
258+
ResolveLatest *bool `json:"resolveLatest,omitempty"`
259+
IDEProxyConfig *IDEProxyConfig `json:"ideProxy,omitempty"`
260+
VSXProxyConfig *VSXProxyConfig `json:"openvsxProxy,omitempty"`
261+
IDEMetricsConfig *IDEMetricsConfig `json:"ideMetrics,omitempty"`
261262
}
262263

263264
type IDEProxyConfig struct {
264265
ServiceAnnotations map[string]string `json:"serviceAnnotations"`
265266
}
266267

268+
type IDEMetricsConfig struct {
269+
EnabledErrorReporting bool `json:"enabledErrorReporting,omitempty"`
270+
GCPProject string `json:"gcpProject,omitempty"`
271+
GCPADCSecret string `json:"gcpAdcSecret,omitempty"`
272+
}
273+
267274
type VSXProxyConfig struct {
268275
ServiceAnnotations map[string]string `json:"serviceAnnotations"`
269276
}

0 commit comments

Comments
 (0)