Skip to content
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

Add wait in between the retries while waiting for failure message to … #6752

Merged
merged 1 commit into from
Sep 29, 2023
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
28 changes: 19 additions & 9 deletions pkg/clustermanager/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import (
)

const (
applyClusterSpecTimeout = 2 * time.Minute
waitForClusterReconcileTimeout = time.Hour
retryBackOff = time.Second
defaultFieldManager = "eks-a-cli"
applyClusterSpecTimeout = 2 * time.Minute
waitForClusterReconcileTimeout = time.Hour
retryBackOff = time.Second
waitForFailureMessageErrorTimeout = 20 * time.Second
defaultFieldManager = "eks-a-cli"
)

// ApplierOpt allows to customize a Applier on construction.
Expand All @@ -29,10 +30,10 @@ type ApplierOpt func(*Applier)
// Applier applies the cluster spec to the management cluster and waits
// until the changes are fully reconciled.
type Applier struct {
log logr.Logger
clientFactory ClientFactory
applyClusterTimeout, waitForClusterReconcile time.Duration
retryBackOff time.Duration
log logr.Logger
clientFactory ClientFactory
applyClusterTimeout, waitForClusterReconcile, waitForFailureMessage time.Duration
retryBackOff time.Duration
}

// NewApplier builds an Applier.
Expand All @@ -42,6 +43,7 @@ func NewApplier(log logr.Logger, clientFactory ClientFactory, opts ...ApplierOpt
clientFactory: clientFactory,
applyClusterTimeout: applyClusterSpecTimeout,
waitForClusterReconcile: waitForClusterReconcileTimeout,
waitForFailureMessage: waitForFailureMessageErrorTimeout,
retryBackOff: retryBackOff,
}

Expand All @@ -58,6 +60,7 @@ func WithApplierNoTimeouts() ApplierOpt {
maxTime := time.Duration(math.MaxInt64)
a.applyClusterTimeout = maxTime
a.waitForClusterReconcile = maxTime
a.waitForFailureMessage = maxTime
}
}

Expand Down Expand Up @@ -130,7 +133,7 @@ func (a Applier) Run(ctx context.Context, spec *cluster.Spec, managementCluster
waitStartTime := time.Now()
retry := a.retrierForWait(waitStartTime)

if err := cluster.WaitFor(ctx, client, spec.Cluster, retrier.New(5*time.Second), func(c *anywherev1.Cluster) error {
if err := cluster.WaitFor(ctx, client, spec.Cluster, a.retrierForFailureMessage(), func(c *anywherev1.Cluster) error {
if c.Status.FailureMessage != nil && *c.Status.FailureMessage != "" {
return fmt.Errorf("cluster has an error: %s", *c.Status.FailureMessage)
}
Expand Down Expand Up @@ -173,3 +176,10 @@ func (a Applier) retrierForWait(waitStartTime time.Time) *retrier.Retrier {
retrier.WithRetryPolicy(retrier.BackOffPolicy(a.retryBackOff)),
)
}

func (a Applier) retrierForFailureMessage() *retrier.Retrier {
return retrier.New(
a.waitForFailureMessage,
retrier.WithRetryPolicy(retrier.BackOffPolicy(a.retryBackOff)),
)
}