Skip to content

Commit

Permalink
try harder when attempting to add or remove annotation from workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sagor999 authored and roboquat committed Mar 1, 2022
1 parent 2cb2dad commit a4dbc1a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/ws-manager/pkg/manager/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ package manager
import (
"context"
"strings"
"time"

"golang.org/x/xerrors"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"

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

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

0 comments on commit a4dbc1a

Please sign in to comment.