Skip to content

Commit e33d526

Browse files
committed
[ws-manager] Remove finalizer once WS is stopped
1 parent 89454d3 commit e33d526

File tree

5 files changed

+661
-6
lines changed

5 files changed

+661
-6
lines changed

components/ws-manager/pkg/manager/monitor.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,6 @@ func (m *Monitor) actOnPodEvent(ctx context.Context, status *api.WorkspaceStatus
372372
}
373373

374374
if status.Phase == api.WorkspacePhase_STOPPING {
375-
if status.Conditions.FinalBackupComplete == api.WorkspaceConditionBool_TRUE {
376-
// we've disposed already - try to remove the finalizer and call it a day
377-
return m.manager.modifyFinalizer(ctx, workspaceID, gitpodFinalizerName, false)
378-
}
379-
380375
var terminated bool
381376
for _, c := range wso.Pod.Status.ContainerStatuses {
382377
if c.Name == "workspace" {
@@ -396,6 +391,11 @@ func (m *Monitor) actOnPodEvent(ctx context.Context, status *api.WorkspaceStatus
396391
}
397392
}
398393

394+
if status.Phase == api.WorkspacePhase_STOPPED {
395+
// we've disposed already - try to remove the finalizer and call it a day
396+
return m.manager.modifyFinalizer(ctx, workspaceID, gitpodFinalizerName, false)
397+
}
398+
399399
return nil
400400
}
401401

components/ws-manager/pkg/manager/status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,14 @@ func (m *Manager) extractStatusFromPod(result *api.WorkspaceStatus, wso workspac
394394

395395
if ds.BackupComplete {
396396
result.Conditions.FinalBackupComplete = api.WorkspaceConditionBool_TRUE
397+
398+
// Finalizer or not - once the backup is complete we consider the pod stopped.
399+
// Once the finalizer is removed, there's no guarantee we see the pod again, because it might be
400+
// deleted too quickly for us to handle. Hence, we consider the workspace stoppped once the backup
401+
// is done, even though the finalizer might still be present.
402+
//
403+
// This runs the risk that a pod might still be present, but is considered stopped.
404+
result.Phase = api.WorkspacePhase_STOPPED
397405
}
398406
result.Repo = ds.GitStatus
399407

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"status": {
3+
"id": "cc1a3979-4e0e-42cc-bba5-a8d66485bdee",
4+
"metadata": {
5+
"owner": "26488517-271b-44f5-8739-96a6d9f6759a",
6+
"meta_id": "amber-swallow-sbhsd9w0",
7+
"started_at": {
8+
"seconds": 1617004536
9+
}
10+
},
11+
"spec": {
12+
"workspace_image": "eu.gcr.io/gitpod-core-dev/registry/workspace-images:4821db66dd61e6944f8940c4328386612ccdb60d542d65f0456d4fd38f51f36a",
13+
"ide_image": "eu.gcr.io/gitpod-core-dev/build/ide/code:cw-wsdaemon-patch.0",
14+
"url": "https://amber-swallow-sbhsd9w0.ws-dev.cw-wsdaemon-patch.staging.gitpod-dev.com",
15+
"timeout": "30m"
16+
},
17+
"phase": 6,
18+
"conditions": {
19+
"final_backup_complete": 1,
20+
"deployed": 1
21+
},
22+
"repo": {
23+
"branch": "master",
24+
"latest_commit": "82457ccee52cfec99c3d491063f9fadfdd78607d"
25+
},
26+
"runtime": {
27+
"node_name": "gke-dev-workload-1-49d27f81-hhx0",
28+
"pod_name": "ws-cc1a3979-4e0e-42cc-bba5-a8d66485bdee",
29+
"node_ip": "10.132.0.14"
30+
},
31+
"auth": {
32+
"owner_token": "{pKaZ75.$$hIiW2z2!-h#HcmldG#U?Dl"
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)