diff --git a/lib/autoupdate/rollout/controller.go b/lib/autoupdate/rollout/controller.go index 2524d3aaaaae0..53a3741f8050a 100644 --- a/lib/autoupdate/rollout/controller.go +++ b/lib/autoupdate/rollout/controller.go @@ -46,7 +46,16 @@ type Controller struct { } // NewController creates a new Controller for the autoupdate_agent_rollout kind. -func NewController(client Client, log *slog.Logger, clock clockwork.Clock) *Controller { +func NewController(client Client, log *slog.Logger, clock clockwork.Clock) (*Controller, error) { + if client == nil { + return nil, trace.BadParameter("missing client") + } + if log == nil { + return nil, trace.BadParameter("missing log") + } + if clock == nil { + return nil, trace.BadParameter("missing clock") + } return &Controller{ clock: clock, log: log, @@ -54,7 +63,7 @@ func NewController(client Client, log *slog.Logger, clock clockwork.Clock) *Cont clt: client, log: log, }, - } + }, nil } // Run the autoupdate_agent_rollout controller. This function returns only when its context is canceled. @@ -75,8 +84,7 @@ func (c *Controller) Run(ctx context.Context) error { return ctx.Err() case <-ticker.Next(): c.log.DebugContext(ctx, "Reconciling autoupdate_agent_rollout") - err := c.tryAndCatch(ctx) - if err != nil { + if err := c.tryAndCatch(ctx); err != nil { c.log.ErrorContext(ctx, "Failed to reconcile autoudpate_agent_controller", "error", err) } } diff --git a/lib/service/service.go b/lib/service/service.go index 0523f98b85350..ef30805a0fa7d 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -2431,7 +2431,10 @@ func (process *TeleportProcess) initAuthService() error { return trace.Wrap(spiffeFedSyncer.Run(process.GracefulExitContext()), "running SPIFFEFederation Syncer") }) - agentRolloutController := rollout.NewController(authServer, logger, process.Clock) + agentRolloutController, err := rollout.NewController(authServer, logger, process.Clock) + if err != nil { + return trace.Wrap(err, "creating the rollout controller") + } process.RegisterFunc("auth.autoupdate_agent_rollout_controller", func() error { return trace.Wrap(agentRolloutController.Run(process.GracefulExitContext()), "running autoupdate_agent_rollout controller") })