Skip to content

Commit

Permalink
Merge pull request #915 from hongweiliu17/STONEINTG-1066
Browse files Browse the repository at this point in the history
fix(STONEINTG-1066): retry when finding application for ITS
  • Loading branch information
hongweiliu17 authored Nov 1, 2024
2 parents a592946 + 2ca974b commit 1874e08
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/controller/scenario/scenario_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/retry"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -73,9 +74,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return ctrl.Result{}, err
}

application, err := r.getApplicationFromScenario(ctx, scenario)
var application *applicationapiv1alpha1.Application
err = retry.OnError(retry.DefaultRetry, func(_ error) bool { return true }, func() error {
application, err = r.getApplicationFromScenario(ctx, scenario)
if err != nil {
logger.Info("Failed to get Application from the IntegrationTestScenario, try again", "error:", err)
}
return err
})
if err != nil {
logger.Info("Failed to get Application from the IntegrationTestScenario", "error:", err)
logger.Error(err, "Failed to get Application from the IntegrationTestScenario after retry", "application", scenario.Spec.Application)
}

adapter := NewAdapter(ctx, application, scenario, logger, loader, r.Client)
Expand Down

0 comments on commit 1874e08

Please sign in to comment.