From c31b8a4383597151e6fb5226c66d3fe530c3ae4a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 17 Jun 2022 16:08:01 -0400 Subject: [PATCH] Fix harmless but nasty-looking error (#2214) If a worker starts up and tries to connect to a controller before the controller has a chance for its rotate roots job to run, it'll spit out a nasty-looking error. It's harmless (things just retry and then work) but scary (`tls: internal error`). Rotating at creation time ensures that it's ready by the time a worker is able to perform any connection against the cluster port. --- internal/daemon/controller/controller.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/daemon/controller/controller.go b/internal/daemon/controller/controller.go index 52eb5c007..3d007799f 100644 --- a/internal/daemon/controller/controller.go +++ b/internal/daemon/controller/controller.go @@ -305,6 +305,17 @@ func New(ctx context.Context, conf *Config) (*Controller, error) { return servers.NewRepositoryStorage(ctx, dbase, dbase, c.kms) } + // Check that credentials are available at startup, to avoid some harmless + // but nasty-looking errors + serversRepo, err := servers.NewRepositoryStorage(ctx, dbase, dbase, c.kms) + if err != nil { + return nil, fmt.Errorf("unable to instantiate worker auth repository: %w", err) + } + err = servers.RotateRoots(ctx, serversRepo) + if err != nil { + return nil, fmt.Errorf("unable to ensure worker auth roots exist: %w", err) + } + return c, nil }