@@ -34,6 +34,7 @@ import (
34
34
wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes"
35
35
"github.com/gitpod-io/gitpod/common-go/log"
36
36
"github.com/gitpod-io/gitpod/common-go/tracing"
37
+ "github.com/gitpod-io/gitpod/common-go/util"
37
38
csapi "github.com/gitpod-io/gitpod/content-service/api"
38
39
wsdaemon "github.com/gitpod-io/gitpod/ws-daemon/api"
39
40
"github.com/gitpod-io/gitpod/ws-manager/api"
@@ -273,7 +274,7 @@ func actOnPodEvent(ctx context.Context, m actingManager, status *api.WorkspaceSt
273
274
if status .Conditions .Failed != "" && ! hasFailureAnnotation {
274
275
// If this marking operation failes that's ok - we'll still continue to shut down the workspace.
275
276
// The failure message won't persist while stopping the workspace though.
276
- err := m .markWorkspace (ctx , workspaceID , addMark (workspaceFailedBeforeStoppingAnnotation , "true" ))
277
+ err := m .markWorkspace (ctx , workspaceID , addMark (workspaceFailedBeforeStoppingAnnotation , util . BooleanTrueString ))
277
278
if err != nil {
278
279
log .WithFields (wsk8s .GetOWIFromObject (& pod .ObjectMeta )).WithError (err ).Debug ("cannot mark workspace as workspaceFailedBeforeStoppingAnnotation" )
279
280
}
@@ -385,22 +386,20 @@ func actOnPodEvent(ctx context.Context, m actingManager, status *api.WorkspaceSt
385
386
_ , alreadyFinalized := wso .Pod .Annotations [startedDisposalAnnotation ]
386
387
387
388
if (terminated || gone ) && ! alreadyFinalized {
388
- if isFailed , ok := wso .Pod .Annotations [workspaceFailedBeforeStoppingAnnotation ]; ok && isFailed == "true" {
389
- if neverReady , ok := wso .Pod .Annotations [workspaceNeverReadyAnnotation ]; ok && neverReady == "true" {
390
- // The workspace is never ready, so there is no need for a finalizer.
391
- if _ , ok := pod .Annotations [workspaceExplicitFailAnnotation ]; ! ok {
392
- failMessage := status .Conditions .Failed
393
- if failMessage == "" {
394
- failMessage = "workspace failed to start."
395
- }
396
- err := m .markWorkspace (ctx , workspaceID , addMark (workspaceExplicitFailAnnotation , failMessage ))
397
- if err != nil {
398
- log .WithError (err ).Error ("was unable to mark workspace as failed" )
399
- }
389
+ if wso .Pod .Annotations [workspaceFailedBeforeStoppingAnnotation ] == util .BooleanTrueString && wso .Pod .Annotations [workspaceNeverReadyAnnotation ] == util .BooleanTrueString {
390
+ // The workspace is never ready, so there is no need for a finalizer.
391
+ if _ , ok := pod .Annotations [workspaceExplicitFailAnnotation ]; ! ok {
392
+ failMessage := status .Conditions .Failed
393
+ if failMessage == "" {
394
+ failMessage = "workspace failed to start."
395
+ }
396
+ err := m .markWorkspace (ctx , workspaceID , addMark (workspaceExplicitFailAnnotation , failMessage ))
397
+ if err != nil {
398
+ log .WithError (err ).Error ("was unable to mark workspace as failed" )
400
399
}
401
-
402
- return m .modifyFinalizer (ctx , workspaceID , gitpodFinalizerName , false )
403
400
}
401
+
402
+ return m .modifyFinalizer (ctx , workspaceID , gitpodFinalizerName , false )
404
403
} else {
405
404
// We start finalizing the workspace content only after the container is gone. This way we ensure there's
406
405
// no process modifying the workspace content as we create the backup.
@@ -941,7 +940,7 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
941
940
m .finalizerMapLock .Unlock ()
942
941
}()
943
942
944
- err = m .manager .markWorkspace (ctx , workspaceID , addMark (startedDisposalAnnotation , "true" ))
943
+ err = m .manager .markWorkspace (ctx , workspaceID , addMark (startedDisposalAnnotation , util . BooleanTrueString ))
945
944
if err != nil {
946
945
log .WithError (err ).Error ("was unable to update pod's start disposal state - this might cause an incorrect disposal state" )
947
946
}
0 commit comments