Skip to content

Commit a61d4b9

Browse files
committed
[ws-manager-mk2] Scrub status fields, add vscode launch.json
1 parent c7e492b commit a61d4b9

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

components/ws-manager-api/go/crd/v1/workspace_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ type PortSpec struct {
154154
type WorkspaceStatus struct {
155155
PodStarts int `json:"podStarts"`
156156
URL string `json:"url,omitempty"`
157-
OwnerToken string `json:"ownerToken,omitempty"`
157+
OwnerToken string `json:"ownerToken,omitempty" scrub:"redact"`
158158

159159
// +kubebuilder:default=Unknown
160160
Phase WorkspacePhase `json:"phase,omitempty"`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch Package",
6+
"type": "go",
7+
"request": "launch",
8+
"mode": "auto",
9+
"program": "${workspaceRoot}/main.go",
10+
"args": ["--config", "example-config.json"]
11+
}
12+
]
13+
}

components/ws-manager-mk2/controllers/workspace_controller.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"sigs.k8s.io/controller-runtime/pkg/log"
2929

3030
wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes"
31+
"github.com/gitpod-io/gitpod/components/scrubber"
3132
"github.com/gitpod-io/gitpod/ws-manager-mk2/pkg/maintenance"
3233
config "github.com/gitpod-io/gitpod/ws-manager/api/config"
3334
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
@@ -133,11 +134,18 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
133134
r.updateMetrics(ctx, &workspace)
134135
r.emitPhaseEvents(ctx, &workspace, oldStatus)
135136

136-
var podStatus *corev1.PodStatus
137+
var scrubbedPodStatus *corev1.PodStatus
137138
if len(workspacePods.Items) > 0 {
138-
podStatus = &workspacePods.Items[0].Status
139+
scrubbedPodStatus = workspacePods.Items[0].Status.DeepCopy()
140+
if err = scrubber.Default.Struct(scrubbedPodStatus); err != nil {
141+
log.Error(err, "failed to scrub pod status")
142+
}
143+
}
144+
scrubbedStatus := workspace.Status.DeepCopy()
145+
if err = scrubber.Default.Struct(scrubbedStatus); err != nil {
146+
log.Error(err, "failed to scrub workspace status")
139147
}
140-
log.Info("updating workspace status", "status", workspace.Status, "podStatus", podStatus)
148+
log.Info("updating workspace status", "status", scrubbedStatus, "podStatus", scrubbedPodStatus)
141149
err = r.Status().Update(ctx, &workspace)
142150
if err != nil {
143151
return errorResultLogConflict(log, fmt.Errorf("failed to update workspace status: %w", err))

components/ws-manager-mk2/example-config.json

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,8 @@
22
"manager": {
33
"namespace": "staging-cw-io-limit-hack",
44
"schedulerName": "",
5+
"secretsNamespace": "workspace-secrets",
56
"seccompProfile": "localhost/workspace_default_cw-ws-manager-mk2.1.json",
6-
"container": {
7-
"workspace": {
8-
"image": "OVERWRITTEN-IN-REQUEST",
9-
"requests": {
10-
"cpu": "1",
11-
"memory": "2Gi",
12-
"ephemeral-storage": ""
13-
},
14-
"limits": {
15-
"cpu": "",
16-
"memory": "",
17-
"ephemeral-storage": ""
18-
}
19-
}
20-
},
217
"timeouts": {
228
"startup": "1h0m0s",
239
"initialization": "30m0s",
@@ -32,7 +18,6 @@
3218
"initProbe": {
3319
"timeout": "1s"
3420
},
35-
"podTemplate": {},
3621
"urlTemplate": "https://{{ .Prefix }}.ws.foo.com",
3722
"portUrlTemplate": "https://{{ .WorkspacePort }}-{{ .Prefix }}.ws.foo.com",
3823
"workspaceHostPath": "/var/gitpod/workspaces",
@@ -57,22 +42,15 @@
5742
"gcloud": {
5843
"credentialsFile": "",
5944
"region": "",
60-
"projectId": "",
61-
"parallelUpload": 0,
62-
"maximumBackupCount": 0
45+
"projectId": ""
6346
},
6447
"minio": {
6548
"endpoint": "minio.default.svc.cluster.local:9000",
6649
"accessKey": "6BYlUKCJraAbBy5U35A4",
6750
"accessKeyFile": "",
6851
"secretKey": "ClclNAidlUwP2ESwEsXt",
6952
"secretKeyFile": "",
70-
"region": "local",
71-
"parallelUpload": 6
72-
},
73-
"backupTrail": {
74-
"enabled": true,
75-
"maxLength": 3
53+
"region": "local"
7654
},
7755
"blobQuota": 5368709120
7856
}
@@ -90,4 +68,4 @@
9068
"prometheus": {
9169
"addr": "127.0.0.1:9500"
9270
}
93-
}
71+
}

components/ws-manager-mk2/ws-manager-mk2.code-workspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"folders": [
33
{ "path": "../common-go" },
44
{ "path": "../ws-daemon" },
5-
{ "path": "../ws-manager" },
65
{ "path": "../ws-manager-api" },
76
{ "path": "../ws-manager-mk2" },
7+
{ "path": "../scrubber" },
88
{ "path": "../server" },
99
{ "path": "../../test" },
1010
{ "path": "../../dev/gpctl" },

0 commit comments

Comments
 (0)