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 new flag '--reconciliation-timeout' #218

Closed
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func main() {
enableManagementPolicies = app.Flag("enable-management-policies", "Enable support for Management Policies.").Default("false").Envar("ENABLE_MANAGEMENT_POLICIES").Bool()
maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("10").Int()
pollInterval = app.Flag("poll", "Poll interval controls how often an individual resource should be checked for drift.").Default("1m").Duration()
reconciliationTimeout = app.Flag("reconciliation-timeout", "The timeout duration for the reconciliation process. In case the deadline exceeds, necessary calls to report errors will still be made.").Default("1m").Duration()
)
kingpin.MustParse(app.Parse(os.Args[1:]))

Expand Down Expand Up @@ -91,6 +92,6 @@ func main() {

kingpin.FatalIfError(err, "Cannot create controller manager")
kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add argocd APIs to scheme")
kingpin.FatalIfError(controller.Setup(mgr, o), "Cannot setup argocd controllers")
kingpin.FatalIfError(controller.Setup(mgr, o, *reconciliationTimeout), "Cannot setup argocd controllers")
kingpin.FatalIfError(mgr.Start(ctrl.SetupSignalHandler()), "Cannot start controller manager")
}
4 changes: 3 additions & 1 deletion pkg/controller/applications/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package applications

import (
"context"
"time"

"github.com/argoproj/argo-cd/v2/pkg/apiclient"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
Expand Down Expand Up @@ -52,7 +53,7 @@ const (
)

// SetupApplication adds a controller that reconciles applications.
func SetupApplication(mgr ctrl.Manager, o xpcontroller.Options) error {
func SetupApplication(mgr ctrl.Manager, o xpcontroller.Options, reconciliationTimeout time.Duration) error {
name := managed.ControllerName(v1alpha1.ApplicationKind)

cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())}
Expand All @@ -64,6 +65,7 @@ func SetupApplication(mgr ctrl.Manager, o xpcontroller.Options) error {
managed.WithLogger(o.Logger.WithValues("controller", name)),
managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))),
managed.WithConnectionPublishers(cps...),
managed.WithTimeout(reconciliationTimeout),
}

if o.Features.Enabled(features.EnableBetaManagementPolicies) {
Expand Down
9 changes: 7 additions & 2 deletions pkg/controller/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package controller

import (

Check failure on line 19 in pkg/controller/argocd.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/crossplane-contrib/provider-argocd (goimports)
xpcontroller "github.com/crossplane/crossplane-runtime/pkg/controller"
ctrl "sigs.k8s.io/controller-runtime"
"time"

"github.com/crossplane-contrib/provider-argocd/pkg/controller/applications"
"github.com/crossplane-contrib/provider-argocd/pkg/controller/applicationsets"
Expand All @@ -30,13 +31,17 @@

// Setup creates all argocd API controllers with the supplied logger and adds
// them to the supplied manager.
func Setup(mgr ctrl.Manager, o xpcontroller.Options) error {
func Setup(mgr ctrl.Manager, o xpcontroller.Options, reconciliationTimeout time.Duration) error {
setupApplicationWithTimeout := func(mgr ctrl.Manager, o xpcontroller.Options) error {
return applications.SetupApplication(mgr, o, reconciliationTimeout)
}

for _, setup := range []func(ctrl.Manager, xpcontroller.Options) error{
config.Setup,
repositories.SetupRepository,
projects.SetupProject,
cluster.SetupCluster,
applications.SetupApplication,
setupApplicationWithTimeout,
applicationsets.SetupApplicationSet,
} {
if err := setup(mgr, o); err != nil {
Expand Down
Loading