Skip to content

Commit

Permalink
[installer] add experimental flag for ide-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
iQQBot authored and roboquat committed Sep 7, 2022
1 parent bf93a7c commit 3fe748c
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 41 deletions.
1 change: 1 addition & 0 deletions .werft/jobs/build/installer/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ EOF`);

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

private configureObservability(slice: string) {
Expand Down
9 changes: 7 additions & 2 deletions install/installer/cmd/testdata/render/aws-setup/output.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3768,7 +3768,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7426,7 +7431,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3686,7 +3686,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7260,7 +7265,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4468,7 +4468,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -8653,7 +8658,7 @@ spec:
metadata:
annotations:
gitpod.io: hello
gitpod.io/checksum_config: 7aca852c0c589f808186529f22f534f9db9fa4ae31546cedc307f7e26ec9c4cf
gitpod.io/checksum_config: 8beda82ff6c689641e3e3d74cfa333942daf49ba5617133a5c6ec21a44408f22
hello: world
creationTimestamp: null
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3827,7 +3827,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7701,7 +7706,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
9 changes: 7 additions & 2 deletions install/installer/cmd/testdata/render/gcp-setup/output.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3657,7 +3657,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7315,7 +7320,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
9 changes: 7 additions & 2 deletions install/installer/cmd/testdata/render/minimal/output.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3993,7 +3993,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7981,7 +7986,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4005,7 +4005,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7993,7 +7998,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4326,7 +4326,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -8425,7 +8430,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3996,7 +3996,12 @@ data:
30
]
}
]
],
"errorReporting": {
"allowComponents": [
"supervisor-frontend"
]
}
},
"debug": false,
"pprof": {
Expand Down Expand Up @@ -7984,7 +7989,7 @@ spec:
template:
metadata:
annotations:
gitpod.io/checksum_config: eca723709a6407bcb546d40271986d74a615e9d48894864f7e344100a905dbcf
gitpod.io/checksum_config: 5f647d019f026f04a85e04ad8e695083db2a70f97ee7199143859879d5d40ebe
creationTimestamp: null
labels:
app: gitpod
Expand Down
7 changes: 7 additions & 0 deletions install/installer/pkg/components/ide-metrics/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,19 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
},
}

errorReporting := config.ErrorReportingConfiguration{
AllowComponents: []string{
"supervisor-frontend",
},
}

cfg := config.ServiceConfiguration{
Server: config.MetricsServerConfiguration{
Port: ContainerPort,
// RateLimits: , // TODO(pd) ratelimit
CounterMetrics: counterMetrics,
HistogramMetrics: histogramMetrics,
ErrorReporting: errorReporting,
},
Prometheus: struct {
Addr string `json:"addr"`
Expand Down
85 changes: 65 additions & 20 deletions install/installer/pkg/components/ide-metrics/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package ide_metrics
import (
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
"github.com/gitpod-io/gitpod/installer/pkg/common"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"

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

volumes := make([]corev1.Volume, 0)
volumeMounts := make([]corev1.VolumeMount, 0)

volumes = append(volumes, corev1.Volume{
Name: VolumeConfig,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
},
},
})

volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: VolumeConfig,
MountPath: "/config",
ReadOnly: true,
})

env := common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
))

_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
if cfg.IDE != nil && cfg.IDE.IDEMetricsConfig != nil {
if cfg.IDE.IDEMetricsConfig.EnabledErrorReporting {
env = append(env, corev1.EnvVar{
Name: "GITPOD_ENABLED_ERROR_REPORTING",
Value: "true",
})

if cfg.IDE.IDEMetricsConfig.GCPADCSecret != "" && cfg.IDE.IDEMetricsConfig.GCPProject != "" {
volumes = append(volumes, corev1.Volume{
Name: "gcp-adc-file",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
},
},
})

volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: "gcp-adc-file",
MountPath: "/gcp",
ReadOnly: true,
})

env = append(env, corev1.EnvVar{
Name: "GOOGLE_PROJECT",
Value: cfg.IDE.IDEMetricsConfig.GCPProject,
})
env = append(env, corev1.EnvVar{
Name: "GOOGLE_APPLICATION_CREDENTIALS",
Value: "/gcp/credentials.json",
})
}
}

}
return nil
})

return []runtime.Object{
&appsv1.Deployment{
TypeMeta: common.TypeMetaDeployment,
Expand Down Expand Up @@ -74,16 +136,8 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.Bool(false),
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
)),
VolumeMounts: []corev1.VolumeMount{
{
Name: VolumeConfig,
MountPath: "/config",
ReadOnly: true,
},
},
Env: env,
VolumeMounts: volumeMounts,
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
TCPSocket: &corev1.TCPSocketAction{
Expand All @@ -97,16 +151,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
*common.KubeRBACProxyContainerWithConfig(ctx),
},
Volumes: []corev1.Volume{
{
Name: VolumeConfig,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
},
},
},
},
Volumes: volumes,
},
},
},
Expand Down
13 changes: 10 additions & 3 deletions install/installer/pkg/config/v1/experimental/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,22 @@ type WebAppWorkspaceClass struct {

type IDEConfig struct {
// Disable resolution of latest images and use bundled latest versions instead
ResolveLatest *bool `json:"resolveLatest,omitempty"`
IDEProxyConfig *IDEProxyConfig `json:"ideProxy,omitempty"`
VSXProxyConfig *VSXProxyConfig `json:"openvsxProxy,omitempty"`
ResolveLatest *bool `json:"resolveLatest,omitempty"`
IDEProxyConfig *IDEProxyConfig `json:"ideProxy,omitempty"`
VSXProxyConfig *VSXProxyConfig `json:"openvsxProxy,omitempty"`
IDEMetricsConfig *IDEMetricsConfig `json:"ideMetrics,omitempty"`
}

type IDEProxyConfig struct {
ServiceAnnotations map[string]string `json:"serviceAnnotations"`
}

type IDEMetricsConfig struct {
EnabledErrorReporting bool `json:"enabledErrorReporting,omitempty"`
GCPProject string `json:"gcpProject,omitempty"`
GCPADCSecret string `json:"gcpAdcSecret,omitempty"`
}

type VSXProxyConfig struct {
ServiceAnnotations map[string]string `json:"serviceAnnotations"`
}
Expand Down

0 comments on commit 3fe748c

Please sign in to comment.