Skip to content

Commit 601019d

Browse files
committed
ws-manager: remove annotation gitpod/failedBeforeStopping
Use annotation `workspaceExplicitFailAnnotation` instead. Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 72a8fa3 commit 601019d

10 files changed

+44
-30
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ const (
5050
// https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#attaching-metadata-to-objects
5151
workspaceInitializerAnnotation = "gitpod/contentInitializer"
5252

53-
// workspaceFailedBeforeStoppingAnnotation marks a workspace as failed even before we tried
54-
// to stop it. We do not extract the failure state from this annotation, but just stabilize
55-
// the state computation.
56-
workspaceFailedBeforeStoppingAnnotation = "gitpod/failedBeforeStopping"
57-
5853
// customTimeoutAnnotation configures the activity timeout of a workspace, i.e. the timeout a user experiences when not using an otherwise active workspace for some time.
5954
// This is handy if you want to prevent a workspace from timing out during lunch break.
6055
customTimeoutAnnotation = "gitpod/customTimeout"
@@ -113,13 +108,6 @@ func (m *Manager) markWorkspace(ctx context.Context, workspaceID string, annotat
113108

114109
for _, a := range annotations {
115110
a.Apply(pod.Annotations)
116-
117-
// Optimization: if we're failing the workspace explicitly, we might as well add the workspaceFailedBeforeStoppingAnnotation
118-
// as well. If we didin't do this here, the monitor would do that for us down the road, but this way need one fewer modification
119-
// of the pod.
120-
if a.Name == workspaceExplicitFailAnnotation {
121-
pod.Annotations[workspaceFailedBeforeStoppingAnnotation] = "true"
122-
}
123111
}
124112

125113
return m.Clientset.Update(ctx, pod)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,22 +277,22 @@ func actOnPodEvent(ctx context.Context, m actingManager, manager *Manager, statu
277277
// the workspace has failed to run/start - shut it down
278278
// we should mark the workspace as failedBeforeStopping - this way the failure status will persist
279279
// while we stop the workspace
280-
_, hasFailureAnnotation := pod.Annotations[workspaceFailedBeforeStoppingAnnotation]
280+
_, hasFailureAnnotation := pod.Annotations[workspaceExplicitFailAnnotation]
281281
if status.Conditions.Failed != "" && !hasFailureAnnotation {
282282
span.LogKV("event", "failed and no failed before stopping annotation")
283283
// If this marking operation failes that's ok - we'll still continue to shut down the workspace.
284284
// The failure message won't persist while stopping the workspace though.
285-
err := m.markWorkspace(ctx, workspaceID, addMark(workspaceFailedBeforeStoppingAnnotation, util.BooleanTrueString))
285+
err := m.markWorkspace(ctx, workspaceID, addMark(workspaceExplicitFailAnnotation, status.Conditions.Failed))
286286
if err != nil {
287-
log.WithError(err).Debug("cannot mark workspace as workspaceFailedBeforeStoppingAnnotation")
287+
log.WithError(err).Debug("cannot mark workspace as workspaceExplicitFailAnnotation")
288288
}
289289
}
290290

291291
// At the moment we call stopWorkspace on the same workspace at least twice:
292292
// First when the workspace originally failed, and
293-
// second when adding the workspaceFailedBeforeStoppingAnnotation which in turn triggers a new pod event.
293+
// second when adding the workspaceExplicitFailAnnotation which in turn triggers a new pod event.
294294
//
295-
// The alternative is to stop the pod only when the workspaceFailedBeforeStoppingAnnotation is present.
295+
// The alternative is to stop the pod only when the workspaceExplicitFailAnnotation is present.
296296
// However, that's much more brittle than stopping the workspace twice (something that Kubernetes can handle).
297297
// It is important that we do not fail here if the pod is already gone, i.e. when we lost the race.
298298
err = m.stopWorkspace(ctx, workspaceID, stopWorkspaceNormallyGracePeriod)
@@ -441,7 +441,7 @@ func actOnPodEvent(ctx context.Context, m actingManager, manager *Manager, statu
441441

442442
span.LogKV("disposalStatusAnnotation", ds)
443443
if terminated && !ds.Status.IsDisposed() {
444-
if wso.Pod.Annotations[workspaceFailedBeforeStoppingAnnotation] == util.BooleanTrueString && wso.Pod.Annotations[workspaceNeverReadyAnnotation] == util.BooleanTrueString {
444+
if wso.Pod.Annotations[workspaceNeverReadyAnnotation] == util.BooleanTrueString {
445445
span.LogKV("event", "failed before stopping and never ready")
446446
// The workspace is never ready, so there is no need for a finalizer.
447447
if _, ok := pod.Annotations[workspaceExplicitFailAnnotation]; !ok {

components/ws-manager/pkg/manager/testdata/actOnPodEvent_brokenScheduler_UNKNOWN00.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Params": {
66
"annotations": [
77
{
8-
"Name": "gitpod/failedBeforeStopping",
9-
"Value": "true",
8+
"Name": "gitpod/explicitFail",
9+
"Value": "MatchNodeSelector: Pod Predicate MatchNodeSelector failed",
1010
"Delete": false
1111
}
1212
],

components/ws-manager/pkg/manager/testdata/actOnPodEvent_cannotPull_004_CREATING00.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Params": {
66
"annotations": [
77
{
8-
"Name": "gitpod/failedBeforeStopping",
9-
"Value": "true",
8+
"Name": "gitpod/explicitFail",
9+
"Value": "cannot pull image: rpc error: code = FailedPrecondition desc = failed to pull and unpack image \"reg.gitpod.io:31001/remote/5031df46-db5e-43ae-91bd-1448305c001d:latest\": failed commit on ref \"layer-sha256:6633ce2524dfae110cac2159a4f8490d198612d12abc1420486c52fbcf30b8b1\": \"layer-sha256:6633ce2524dfae110cac2159a4f8490d198612d12abc1420486c52fbcf30b8b1\" failed size validation: 33554502 != 64598931: failed precondition",
1010
"Delete": false
1111
}
1212
],

components/ws-manager/pkg/manager/testdata/actOnPodEvent_errimgpull.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Params": {
66
"annotations": [
77
{
8-
"Name": "gitpod/failedBeforeStopping",
9-
"Value": "true",
8+
"Name": "gitpod/explicitFail",
9+
"Value": "cannot pull image: rpc error: code = Unknown desc = Error response from daemon: Get https://registry.staging-cw-minio-core.svc.cluster.local/v1/_ping: dial tcp: lookup registry.staging-cw-minio-core.svc.cluster.local: no such host",
1010
"Delete": false
1111
}
1212
],

components/ws-manager/pkg/manager/testdata/actOnPodEvent_failedLogs_RUNNING00.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Params": {
66
"annotations": [
77
{
8-
"Name": "gitpod/failedBeforeStopping",
9-
"Value": "true",
8+
"Name": "gitpod/explicitFail",
9+
"Value": "IDE failed to start: fork/exec /theia/node_modules/@gitpod/gitpod-ide/startup.sh: no such file or directory",
1010
"Delete": false
1111
}
1212
],

components/ws-manager/pkg/manager/testdata/actOnPodEvent_failedPending_evicted_UNKNOWN01.golden

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
22
"actions": [
3+
{
4+
"Func": "markWorkspace",
5+
"Params": {
6+
"annotations": [
7+
{
8+
"Name": "gitpod/explicitFail",
9+
"Value": "Evicted: Pod The node was low on resource: [DiskPressure]. ",
10+
"Delete": false
11+
}
12+
],
13+
"workspaceID": "cecf2a75-7225-4056-a125-fa3144b9c012"
14+
}
15+
},
316
{
417
"Func": "stopWorkspace",
518
"Params": {

components/ws-manager/pkg/manager/testdata/actOnPodEvent_failedWorkspaceMount_PENDING00.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Params": {
66
"annotations": [
77
{
8-
"Name": "gitpod/failedBeforeStopping",
9-
"Value": "true",
8+
"Name": "gitpod/explicitFail",
9+
"Value": "cannot mount workspace",
1010
"Delete": false
1111
}
1212
],

components/ws-manager/pkg/manager/testdata/actOnPodEvent_ideFailedToStart_005_RUNNING00.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Params": {
66
"annotations": [
77
{
8-
"Name": "gitpod/failedBeforeStopping",
9-
"Value": "true",
8+
"Name": "gitpod/explicitFail",
9+
"Value": "IDE failed to start: exit status 127",
1010
"Delete": false
1111
}
1212
],

components/ws-manager/pkg/manager/testdata/actOnPodEvent_stuckInStopping_RUNNING00.golden

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
22
"actions": [
3+
{
4+
"Func": "markWorkspace",
5+
"Params": {
6+
"annotations": [
7+
{
8+
"Name": "gitpod/explicitFail",
9+
"Value": "container workspace ran with an error: exit code 1",
10+
"Delete": false
11+
}
12+
],
13+
"workspaceID": "48f13cc4-6311-48c2-950a-4b7ddedc3037"
14+
}
15+
},
316
{
417
"Func": "stopWorkspace",
518
"Params": {

0 commit comments

Comments
 (0)