From 0f1cc86e71ae549051ac81e75e7e00f3db49fe6e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 11 May 2021 01:07:26 +0200 Subject: [PATCH] outposts/ak: updater providers automatically every 150 seconds Signed-off-by: Jens Langhammer --- outpost/pkg/ak/api.go | 4 ++++ outpost/pkg/ak/api_ws.go | 11 +++++++++++ outpost/pkg/proxy/api.go | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/outpost/pkg/ak/api.go b/outpost/pkg/ak/api.go index c4ead9265..62571163b 100644 --- a/outpost/pkg/ak/api.go +++ b/outpost/pkg/ak/api.go @@ -90,6 +90,10 @@ func (a *APIController) Start() error { a.logger.Debug("Starting WS Health notifier...") a.startWSHealth() }() + go func() { + a.logger.Debug("Starting Interval updater...") + a.startIntervalUpdater() + }() go func() { err := a.Server.Start() if err != nil { diff --git a/outpost/pkg/ak/api_ws.go b/outpost/pkg/ak/api_ws.go index 235247ec1..cdf891ed0 100644 --- a/outpost/pkg/ak/api_ws.go +++ b/outpost/pkg/ak/api_ws.go @@ -111,3 +111,14 @@ func (ac *APIController) startWSHealth() { } } } + +func (ac *APIController) startIntervalUpdater() { + logger := ac.logger.WithField("loop", "interval-updater") + ticker := time.NewTicker(time.Second * 150) + for ; true; <-ticker.C { + err := ac.Server.Refresh() + if err != nil { + logger.WithError(err).Debug("Failed to update") + } + } +} diff --git a/outpost/pkg/proxy/api.go b/outpost/pkg/proxy/api.go index a17d9d446..87d982a78 100644 --- a/outpost/pkg/proxy/api.go +++ b/outpost/pkg/proxy/api.go @@ -16,7 +16,6 @@ func (s *Server) Refresh() error { s.logger.Debug("Providers have not changed, not updating") return nil } - s.logger.Tracef("%+v\n", providers) bundles := s.bundleProviders(providers) s.updateHTTPServer(bundles) return nil