From 019a6e0774ec582b955d8bc7e4b02a9e6dc4f6e5 Mon Sep 17 00:00:00 2001 From: Sebastian Florek Date: Thu, 19 Sep 2024 16:51:42 +0200 Subject: [PATCH] fix reconcile default polling time --- cmd/agent/args/args.go | 10 +++++----- cmd/agent/console.go | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/agent/args/args.go b/cmd/agent/args/args.go index 8e80a6be..8b424e99 100644 --- a/cmd/agent/args/args.go +++ b/cmd/agent/args/args.go @@ -29,8 +29,8 @@ const ( defaultRefreshInterval = "2m" defaultRefreshIntervalDuration = 2 * time.Minute - defaultPollInterval = "30s" - defaultPollIntervalDuration = 30 * time.Second + defaultPollInterval = "2m" + defaultPollIntervalDuration = 2 * time.Minute defaultPollJitter = "15s" defaultPollJitterDuration = 15 * time.Second @@ -41,8 +41,8 @@ const ( defaultManifestCacheTTL = "1h" defaultManifestCacheTTLDuration = time.Hour - defaultControllerCacheTTL = "30s" - defaultControllerCacheTTLDuration = 30 * time.Second + defaultControllerCacheTTL = "2m" + defaultControllerCacheTTLDuration = 2 * time.Minute defaultRestoreNamespace = "velero" @@ -67,7 +67,7 @@ var ( argProbeAddr = flag.String("health-probe-bind-address", defaultProbeAddress, "The address the probe endpoint binds to.") argMetricsAddr = flag.String("metrics-bind-address", defaultMetricsAddress, "The address the metric endpoint binds to.") argProcessingTimeout = flag.String("processing-timeout", defaultProcessingTimeout, "Maximum amount of time to spend trying to process queue item.") - argRefreshInterval = flag.String("refresh-interval", defaultRefreshInterval, "Time interval to recheck the websocket connection.") + argRefreshInterval = flag.String("refresh-interval", defaultRefreshInterval, "DEPRECATED: Time interval to poll resources from the Console API.") argPollInterval = flag.String("poll-interval", defaultPollInterval, "Time interval to poll resources from the Console API.") // TODO: ensure this arg can be safely renamed without causing breaking changes. argPollJitter = flag.String("refresh-jitter", defaultPollJitter, "Randomly selected jitter time up to the provided duration will be added to the poll interval.") diff --git a/cmd/agent/console.go b/cmd/agent/console.go index 032be226..79e0d411 100644 --- a/cmd/agent/console.go +++ b/cmd/agent/console.go @@ -2,6 +2,7 @@ package main import ( "os" + "time" "github.com/pluralsh/deployment-operator/cmd/agent/args" "github.com/pluralsh/deployment-operator/internal/utils" @@ -37,6 +38,12 @@ func initConsoleManagerOrDie() *consolectrl.Manager { return mgr } +const ( + // Use custom (short) poll intervals for these reconcilers. + pipelineGatesPollInterval = 30 * time.Second + stacksPollInterval = 30 * time.Second +) + func registerConsoleReconcilersOrDie( mgr *controller.Manager, config *rest.Config, @@ -49,7 +56,7 @@ func registerConsoleReconcilersOrDie( }) mgr.AddReconcilerOrDie(pipelinegates.Identifier, func() (controller.Reconciler, error) { - r, err := pipelinegates.NewGateReconciler(consoleClient, k8sClient, config, args.PollInterval()) + r, err := pipelinegates.NewGateReconciler(consoleClient, k8sClient, config, pipelineGatesPollInterval) return r, err }) @@ -70,7 +77,7 @@ func registerConsoleReconcilersOrDie( os.Exit(1) } - r := stacks.NewStackReconciler(consoleClient, k8sClient, args.ControllerCacheTTL(), args.PollInterval(), namespace, args.ConsoleUrl(), args.DeployToken()) + r := stacks.NewStackReconciler(consoleClient, k8sClient, args.ControllerCacheTTL(), stacksPollInterval, namespace, args.ConsoleUrl(), args.DeployToken()) return r, nil }) }