From 966de967953448b7358fbbfc26e7905ad64b71a2 Mon Sep 17 00:00:00 2001 From: ldelossa Date: Thu, 4 Feb 2021 18:28:52 -0500 Subject: [PATCH] updates: perform implicit run when moving libvuln to non-blocking the initial updater run was removed. this caused libvuln not to issue a run of the update manager until the first interval tick which by default is 30 minutes. this update adds a implicit call to run before setting up the time.Tickers. Signed-off-by: ldelossa --- libvuln/updates/manager.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libvuln/updates/manager.go b/libvuln/updates/manager.go index dc3beeb59..f1f541ad1 100644 --- a/libvuln/updates/manager.go +++ b/libvuln/updates/manager.go @@ -98,6 +98,9 @@ func NewManager(ctx context.Context, store vulnstore.Updater, pool *pgxpool.Pool // // Start is designed to be ran as a go routine. // Cancel the provided ctx to end the updater loop. +// +// Start must only be called once between context +// cancelations. func (m *Manager) Start(ctx context.Context) error { log := zerolog.Ctx(ctx).With(). Str("component", "libvuln/updates/Manager.Start"). @@ -108,9 +111,12 @@ func (m *Manager) Start(ctx context.Context) error { } log.Info().Str("interval", m.interval.String()).Msg("starting background updates") + // perform the initial run + m.Run(ctx) + + // perform run on every tick t := time.NewTicker(m.interval) defer t.Stop() - for { select { case <-ctx.Done():