From fc131de305472f341dbd5b2ce3e8f81b0d69223b Mon Sep 17 00:00:00 2001 From: Hugo Shaka Date: Tue, 31 Dec 2024 11:25:18 -0500 Subject: [PATCH] Enable strategies in the autoupdate rollout controller (#50635) --- constants.go | 3 +++ lib/autoupdate/rollout/controller.go | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/constants.go b/constants.go index 63ba08b791c46..ff9356f2b63d6 100644 --- a/constants.go +++ b/constants.go @@ -288,6 +288,9 @@ const ( // ComponentUpdater represents the teleport-update binary. ComponentUpdater = "updater" + // ComponentRolloutController represents the autoupdate_agent_rollout controller. + ComponentRolloutController = "rollout-controller" + // VerboseLogsEnvVar forces all logs to be verbose (down to DEBUG level) VerboseLogsEnvVar = "TELEPORT_DEBUG" diff --git a/lib/autoupdate/rollout/controller.go b/lib/autoupdate/rollout/controller.go index 7adbb1d009a15..7ac3861e2bce0 100644 --- a/lib/autoupdate/rollout/controller.go +++ b/lib/autoupdate/rollout/controller.go @@ -26,6 +26,7 @@ import ( "github.com/gravitational/trace" "github.com/jonboulle/clockwork" + "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/utils/retryutils" "github.com/gravitational/teleport/lib/utils/interval" ) @@ -65,15 +66,27 @@ func NewController(client Client, log *slog.Logger, clock clockwork.Clock, perio period = defaultReconcilerPeriod } + log = log.With(teleport.ComponentLabel, teleport.ComponentRolloutController) + + haltOnError, err := newHaltOnErrorStrategy(log) + if err != nil { + return nil, trace.Wrap(err, "failed to initialize halt-on-error strategy") + } + timeBased, err := newTimeBasedStrategy(log) + if err != nil { + return nil, trace.Wrap(err, "failed to initialize time-based strategy") + } + return &Controller{ clock: clock, log: log, reconciler: reconciler{ - clt: client, - log: log, - clock: clock, + clt: client, + log: log, + clock: clock, rolloutStrategies: []rolloutStrategy{ - // TODO(hugoShaka): add the strategies here as we implement them + timeBased, + haltOnError, }, }, period: period,