Skip to content

Commit

Permalink
Add wait in between the retries while waiting for failure message to …
Browse files Browse the repository at this point in the history
…be empty for upgrade management task
  • Loading branch information
panktishah26 committed Sep 29, 2023
1 parent c6ff83b commit 5ef637b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 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 Down Expand Up @@ -130,7 +131,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, retrier.New(waitForFailureMessageErrorTimeout, retrier.WithRetryPolicy(failureMessageRetryPolicy)), 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 +174,7 @@ func (a Applier) retrierForWait(waitStartTime time.Time) *retrier.Retrier {
retrier.WithRetryPolicy(retrier.BackOffPolicy(a.retryBackOff)),
)
}

func failureMessageRetryPolicy(totalRetries int, err error) (retry bool, wait time.Duration) {
return true, 5 * time.Second
}

0 comments on commit 5ef637b

Please sign in to comment.