Skip to content

Commit

Permalink
Address tim's feedback
Browse files Browse the repository at this point in the history
Co-authored-by: rosstimothy <[email protected]>
  • Loading branch information
hugoShaka and rosstimothy committed Nov 27, 2024
1 parent 62a94fd commit 327039a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/autoupdate/rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ 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,
reconciler: reconciler{
clt: client,
log: log,
},
}
}, nil
}

// Run the autoupdate_agent_rollout controller. This function returns only when its context is canceled.
Expand All @@ -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)
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down

0 comments on commit 327039a

Please sign in to comment.