Skip to content

Commit a4dbc1a

Browse files
sagor999roboquat
authored andcommitted
try harder when attempting to add or remove annotation from workspaces
1 parent 2cb2dad commit a4dbc1a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ package manager
77
import (
88
"context"
99
"strings"
10+
"time"
1011

1112
"golang.org/x/xerrors"
13+
"k8s.io/apimachinery/pkg/util/wait"
1214
"k8s.io/client-go/util/retry"
1315

1416
"github.com/gitpod-io/gitpod/common-go/log"
@@ -79,8 +81,17 @@ const (
7981

8082
// markWorkspaceAsReady adds annotations to a workspace pod
8183
func (m *Manager) markWorkspace(ctx context.Context, workspaceID string, annotations ...*annotation) error {
84+
// use custom backoff, as default one fails after 1.5s, this one will try for about 25s
85+
// we want to try harder to remove or add annotation, as failure to remove "gitpod/never-ready" annotation
86+
// would cause whole workspace to be marked as failed, hence the reason to try harder here.
87+
var backoff = wait.Backoff{
88+
Steps: 7,
89+
Duration: 100 * time.Millisecond,
90+
Factor: 2.0,
91+
Jitter: 0.1,
92+
}
8293
// Retry on failure. Sometimes this doesn't work because of concurrent modification. The Kuberentes way is to just try again after waiting a bit.
83-
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
94+
err := retry.RetryOnConflict(backoff, func() error {
8495
pod, err := m.findWorkspacePod(ctx, workspaceID)
8596
if err != nil {
8697
return xerrors.Errorf("cannot find workspace %s: %w", workspaceID, err)

0 commit comments

Comments
 (0)