Skip to content

[ws-manager] add config setting that allows to debug workspaces #10410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/ws-manager-api/go/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ type Configuration struct {
WorkspaceClusterHost string `json:"workspaceClusterHost"`
// WorkspaceClasses provide different resource classes for workspaces
WorkspaceClasses map[string]*WorkspaceClass `json:"workspaceClass"`
// DebugWorkspacePod adds extra finalizer to workspace to prevent it from shutting down. Helps to debug.
DebugWorkspacePod bool `json:"debugWorkspacePod,omitempty"`
}

type WorkspaceClass struct {
Expand Down
4 changes: 4 additions & 0 deletions components/ws-manager/pkg/manager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ func (m *Manager) createDefiniteWorkspacePod(startContext *startWorkspaceContext
},
}

if m.Config.DebugWorkspacePod {
pod.Finalizers = append(pod.Finalizers, "gitpod.io/debugfinalizer")
}

ffidx := make(map[api.WorkspaceFeatureFlag]struct{})
for _, feature := range startContext.Request.Spec.FeatureFlags {
if _, seen := ffidx[feature]; seen {
Expand Down
4 changes: 3 additions & 1 deletion components/ws-manager/pkg/manager/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func TestCreateDefiniteWorkspacePod(t *testing.T) {
CACertSecret string `json:"caCertSecret,omitempty"`
Classes map[string]WorkspaceClass `json:"classes,omitempty"`

EnforceAffinity bool `json:"enforceAffinity,omitempty"`
EnforceAffinity bool `json:"enforceAffinity,omitempty"`
DebugWorkspacePod bool `json:"debugWorkspacePod,omitempty"`
}
type gold struct {
Pod corev1.Pod `json:"reason,omitempty"`
Expand All @@ -69,6 +70,7 @@ func TestCreateDefiniteWorkspacePod(t *testing.T) {

mgmtCfg := forTestingOnlyManagerConfig()
mgmtCfg.WorkspaceCACertSecret = fixture.CACertSecret
mgmtCfg.DebugWorkspacePod = fixture.DebugWorkspacePod

if fixture.Classes == nil {
fixture.Classes = make(map[string]WorkspaceClass)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
{
"reason": {
"metadata": {
"name": "ws-test",
"namespace": "default",
"creationTimestamp": null,
"labels": {
"app": "gitpod",
"component": "workspace",
"gitpod.io/networkpolicy": "default",
"gitpod.io/workspaceClass": "default",
"gpwsman": "true",
"headless": "false",
"metaID": "foobar",
"owner": "tester",
"workspaceID": "test",
"workspaceType": "regular"
},
"annotations": {
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
"container.apparmor.security.beta.kubernetes.io/workspace": "unconfined",
"gitpod.io/attemptingToCreate": "true",
"gitpod/admission": "admit_owner_only",
"gitpod/contentInitializer": "GmcKZXdvcmtzcGFjZXMvY3J5cHRpYy1pZC1nb2VzLWhlcmcvZmQ2MjgwNGItNGNhYi0xMWU5LTg0M2EtNGU2NDUzNzMwNDhlLnRhckBnaXRwb2QtZGV2LXVzZXItY2hyaXN0ZXN0aW5n",
"gitpod/id": "test",
"gitpod/imageSpec": "Cghzb21lLXJlZhI0ZXUuZ2NyLmlvL2dpdHBvZC1jb3JlLWRldi9idWlkL3RoZWlhLWlkZTpzb21ldmVyc2lvbg==",
"gitpod/never-ready": "true",
"gitpod/ownerToken": "%7J'[Of/8NDiWE+9F,I6^Jcj_1\u0026}-F8p",
"gitpod/servicePrefix": "foobarservice",
"gitpod/traceid": "",
"gitpod/url": "test-foobarservice-gitpod.io",
"seccomp.security.alpha.kubernetes.io/pod": "localhost/workspace-default"
},
"finalizers": [
"gitpod.io/finalizer",
"gitpod.io/debugfinalizer"
]
},
"spec": {
"volumes": [
{
"name": "vol-this-workspace",
"hostPath": {
"path": "/tmp/workspaces/test",
"type": "DirectoryOrCreate"
}
},
{
"name": "daemon-mount",
"hostPath": {
"path": "/tmp/workspaces/test-daemon",
"type": "DirectoryOrCreate"
}
}
],
"containers": [
{
"name": "workspace",
"image": "registry-facade:8080/remote/test",
"command": [
"/.supervisor/workspacekit",
"ring0"
],
"ports": [
{
"containerPort": 23000
},
{
"name": "supervisor",
"containerPort": 22999
}
],
"env": [
{
"name": "GITPOD_REPO_ROOT",
"value": "/workspace"
},
{
"name": "GITPOD_REPO_ROOTS",
"value": "/workspace"
},
{
"name": "GITPOD_CLI_APITOKEN",
"value": "Ab=5=rRA*9:C'T{;RRB\u003e]vK2p6`fFfrS"
},
{
"name": "GITPOD_OWNER_ID",
"value": "tester"
},
{
"name": "GITPOD_WORKSPACE_ID",
"value": "foobar"
},
{
"name": "GITPOD_INSTANCE_ID",
"value": "test"
},
{
"name": "GITPOD_THEIA_PORT",
"value": "23000"
},
{
"name": "THEIA_WORKSPACE_ROOT",
"value": "/workspace"
},
{
"name": "GITPOD_HOST",
"value": "gitpod.io"
},
{
"name": "GITPOD_WORKSPACE_URL",
"value": "test-foobarservice-gitpod.io"
},
{
"name": "THEIA_SUPERVISOR_ENDPOINT",
"value": ":22999"
},
{
"name": "THEIA_WEBVIEW_EXTERNAL_ENDPOINT",
"value": "webview-{{hostname}}"
},
{
"name": "THEIA_MINI_BROWSER_HOST_PATTERN",
"value": "browser-{{hostname}}"
},
{
"name": "GITPOD_GIT_USER_NAME",
"value": "usernameGoesHere"
},
{
"name": "GITPOD_GIT_USER_EMAIL",
"value": "[email protected]"
},
{
"name": "GITPOD_INTERVAL",
"value": "30000"
},
{
"name": "GITPOD_MEMORY",
"value": "999"
}
],
"resources": {
"limits": {
"cpu": "900m",
"memory": "1G"
},
"requests": {
"cpu": "899m",
"ephemeral-storage": "5Gi",
"memory": "999M"
}
},
"volumeMounts": [
{
"name": "vol-this-workspace",
"mountPath": "/workspace",
"mountPropagation": "HostToContainer"
},
{
"name": "daemon-mount",
"mountPath": "/.workspace",
"mountPropagation": "HostToContainer"
}
],
"readinessProbe": {
"httpGet": {
"path": "/_supervisor/v1/status/content/wait/true",
"port": 22999,
"scheme": "HTTP"
},
"initialDelaySeconds": 2,
"timeoutSeconds": 1,
"periodSeconds": 1,
"successThreshold": 1,
"failureThreshold": 600
},
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent",
"securityContext": {
"capabilities": {
"add": [
"AUDIT_WRITE",
"FSETID",
"KILL",
"NET_BIND_SERVICE",
"SYS_PTRACE"
],
"drop": [
"SETPCAP",
"CHOWN",
"NET_RAW",
"DAC_OVERRIDE",
"FOWNER",
"SYS_CHROOT",
"SETFCAP",
"SETUID",
"SETGID"
]
},
"privileged": false,
"runAsUser": 33333,
"runAsGroup": 33333,
"runAsNonRoot": true,
"readOnlyRootFilesystem": false,
"allowPrivilegeEscalation": true
}
}
],
"restartPolicy": "Never",
"serviceAccountName": "workspace",
"automountServiceAccountToken": false,
"securityContext": {},
"hostname": "foobar",
"affinity": {
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "gitpod.io/workload_workspace_regular",
"operator": "Exists"
},
{
"key": "gitpod.io/ws-daemon_ready_ns_default",
"operator": "Exists"
},
{
"key": "gitpod.io/registry-facade_ready_ns_default",
"operator": "Exists"
}
]
}
]
}
}
},
"tolerations": [
{
"key": "node.kubernetes.io/disk-pressure",
"operator": "Exists",
"effect": "NoExecute"
},
{
"key": "node.kubernetes.io/memory-pressure",
"operator": "Exists",
"effect": "NoExecute"
},
{
"key": "node.kubernetes.io/network-unavailable",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 30
}
],
"enableServiceLinks": false
},
"status": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"debugWorkspacePod": true,
"spec": {
"ideImage": {
"webRef": "eu.gcr.io/gitpod-core-dev/buid/theia-ide:someversion"
},
"workspaceImage": "some-ref",
"initializer": {
"snapshot": {
"snapshot": "workspaces/cryptic-id-goes-herg/fd62804b-4cab-11e9-843a-4e645373048e.tar@gitpod-dev-user-christesting"
}
},
"git": {
"username": "usernameGoesHere",
"email": "[email protected]"
}
}
}