Skip to content

Commit

Permalink
[ws-manager] Recognise terminated pods as running
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel committed Aug 27, 2021
1 parent 3c30d1d commit 8e7d668
Show file tree
Hide file tree
Showing 10 changed files with 1,267 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/ws-manager/pkg/manager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,21 @@ func extractFailure(wso workspaceObjects) (string, *api.WorkspacePhase) {
// we would not be here as we've checked for a DeletionTimestamp prior. So let's find out why the
// container is terminating.
if terminationState.ExitCode != 0 && terminationState.Message != "" {
var phase *api.WorkspacePhase
if !isPodBeingDeleted(pod) {
// If the wrote a termination message and is not currently being deleted,
// then it must have been/be running. If we did not force the phase here,
// we'd be in unknown.
c := api.WorkspacePhase_RUNNING
phase = &c
}

// the container itself told us why it was terminated - use that as failure reason
return extractFailureFromLogs([]byte(terminationState.Message)), nil
return extractFailureFromLogs([]byte(terminationState.Message)), phase
} else if terminationState.Reason == "Error" {
if !isPodBeingDeleted(pod) && terminationState.ExitCode != containerKilledExitCode {
return fmt.Sprintf("container %s ran with an error: exit code %d", cs.Name, terminationState.ExitCode), nil
phase := api.WorkspacePhase_RUNNING
return fmt.Sprintf("container %s ran with an error: exit code %d", cs.Name, terminationState.ExitCode), &phase
}
} else if terminationState.Reason == "Completed" {
if wso.IsWorkspaceHeadless() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"actions": [
{
"Func": "markWorkspace",
"Params": {
"annotations": [
{
"Name": "gitpod/failedBeforeStopping",
"Value": "true",
"Delete": false
}
],
"workspaceID": "f07f0f2e-08fb-433a-8282-fef07b596909"
}
},
{
"Func": "stopWorkspace",
"Params": {
"gracePeriod": 30000000000,
"workspaceID": "f07f0f2e-08fb-433a-8282-fef07b596909"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"actions": [
{
"Func": "markWorkspace",
"Params": {
"annotations": [
{
"Name": "gitpod/failedBeforeStopping",
"Value": "true",
"Delete": false
}
],
"workspaceID": "9ff933b3-d487-4b45-a966-e715767f91df"
}
},
{
"Func": "stopWorkspace",
"Params": {
"gracePeriod": 30000000000,
"workspaceID": "9ff933b3-d487-4b45-a966-e715767f91df"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"actions": [
{
"Func": "stopWorkspace",
"Params": {
"gracePeriod": 30000000000,
"workspaceID": "48f13cc4-6311-48c2-950a-4b7ddedc3037"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
"timeout": "30m"
},
"phase": 4,
"conditions": {
"failed": "IDE failed to start: fork/exec /theia/node_modules/@gitpod/gitpod-ide/startup.sh: no such file or directory",
"service_exists": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"status": {
"id": "9ff933b3-d487-4b45-a966-e715767f91df",
"metadata": {
"owner": "d20bf9c2-e802-43ba-b647-ffa89f8ff17e",
"meta_id": "rose-donkey-wfapr095",
"started_at": {
"seconds": 1629308528
}
},
"spec": {
"workspace_image": "eu.gcr.io/gitpod-dev/workspace-images:aeed577d8b4785088120a7d24d056ee2d553a69d2bcc413a572e82a3039cd6cd",
"ide_image": "eu.gcr.io/gitpod-core-dev/build/ide/code:commit-0941a0805dc3c7345c45bd926317eaf045d4b7fb",
"url": "https://rose-donkey-wfapr095.ws-eu14.gitpod.io",
"timeout": "30m"
},
"phase": 4,
"conditions": {
"failed": "IDE failed to start: exit status 127",
"service_exists": 1,
"deployed": 1
},
"runtime": {
"node_name": "gke-gp-prod-ws-eu14-eu-workspace-pool-b6e0759a-3lb1",
"pod_name": "ws-9ff933b3-d487-4b45-a966-e715767f91df",
"node_ip": "10.132.0.110"
},
"auth": {
"owner_token": "-Jlxl8PUpKylHGFNjZaYXSmhg8qlFbck"
}
}
}
Loading

0 comments on commit 8e7d668

Please sign in to comment.