From 0655683ca1e4387e4a72f97360d49f99a61352be Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Fri, 23 Aug 2024 11:00:27 -0500 Subject: [PATCH] Try to reconnect broken providers before scan Requires https://github.com/mondoohq/cnquery/pull/4591 --- policy/scan/local_scanner.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/policy/scan/local_scanner.go b/policy/scan/local_scanner.go index 86641db2..79da51c2 100644 --- a/policy/scan/local_scanner.go +++ b/policy/scan/local_scanner.go @@ -414,6 +414,10 @@ func (s *LocalScanner) distributeJob(job *Job, ctx context.Context, upstream *up asset := batch[i].Asset runtime := batch[i].Runtime + if err := runtime.EnsureProvidersConnected(); err != nil { + log.Error().Err(err).Msg("could not connect to providers") + } + log.Debug().Interface("platform", asset.Platform).Str("name", asset.Name).Msg("start scan") // Make sure the context has not been canceled in the meantime. Note that this approach works only for single threaded execution. If we have more than 1 thread calling this function,