Skip to content

try harder when attempting to add or remove annotation from workspaces #8519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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