From 5ef637b34ac63c1d5c676a8a59f9f903cf7805db Mon Sep 17 00:00:00 2001 From: Pankti Shah Date: Fri, 29 Sep 2023 13:55:40 -0700 Subject: [PATCH] Add wait in between the retries while waiting for failure message to be empty for upgrade management task --- pkg/clustermanager/applier.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/clustermanager/applier.go b/pkg/clustermanager/applier.go index cdda11d14d720..11e64ff9af2a7 100644 --- a/pkg/clustermanager/applier.go +++ b/pkg/clustermanager/applier.go @@ -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. @@ -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) } @@ -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 +}