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

fix(STONEINTG-1087): retry longer to fetch App from ITS, and stop processing if not found #993

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
25 changes: 22 additions & 3 deletions internal/controller/scenario/scenario_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@

import (
"context"
"time"

h "github.com/konflux-ci/integration-service/helpers"

Check failure on line 23 in internal/controller/scenario/scenario_controller.go

View workflow job for this annotation

GitHub Actions / Go linters

package "github.com/konflux-ci/integration-service/helpers" is being imported more than once (ST1019)
"github.com/konflux-ci/integration-service/loader"

"github.com/go-logr/logr"
applicationapiv1alpha1 "github.com/konflux-ci/application-api/api/v1alpha1"
"github.com/konflux-ci/integration-service/api/v1beta2"
"github.com/konflux-ci/integration-service/helpers"

Check failure on line 29 in internal/controller/scenario/scenario_controller.go

View workflow job for this annotation

GitHub Actions / Go linters

other import of "github.com/konflux-ci/integration-service/helpers"
"github.com/konflux-ci/operator-toolkit/controller"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -75,15 +78,31 @@
}

var application *applicationapiv1alpha1.Application
err = retry.OnError(retry.DefaultRetry, func(_ error) bool { return true }, func() error {
var CustomRetry = wait.Backoff{
Steps: 5,
Duration: 10 * time.Second, // Default was 10 milliseconds
Factor: 1.0,
Jitter: 0.1,
}
err = retry.OnError(CustomRetry, 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)
logger.Info("Failed to get Application from the IntegrationTestScenario, trying again", "error:", err)
}
return err
})
if err != nil {
logger.Error(err, "Failed to get Application from the IntegrationTestScenario after retry", "application", scenario.Spec.Application)
errString := "Failed to get Application from the IntegrationTestScenario even after retrying"
logger.Error(err, errString, "application", scenario.Spec.Application)
patch := client.MergeFrom(scenario.DeepCopy())
h.SetScenarioIntegrationStatusAsInvalid(scenario, errString)
err := r.Client.Status().Patch(ctx, scenario, patch)
if err != nil {
logger.Error(err, "Failed to update Scenario as Invalid")
return ctrl.Result{}, err
}
logger.Info("Marked the IntegrationTestScenario as Invalid, will stop processing it", "error:", err)
return ctrl.Result{}, nil
}

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