From a45125014f6098bcaeabc905d3b3910459687bc8 Mon Sep 17 00:00:00 2001 From: hugoShaka Date: Wed, 27 Nov 2024 15:00:57 -0500 Subject: [PATCH] address tim's feedback --- lib/autoupdate/rollout/controller.go | 13 +++++++++++-- lib/service/service.go | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/autoupdate/rollout/controller.go b/lib/autoupdate/rollout/controller.go index 6648a594b410b..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. 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") })