From f9a7aa27ffa7dd4276a962b4ad35f30e1af8f2cb Mon Sep 17 00:00:00 2001 From: amirylm Date: Wed, 20 Mar 2024 15:42:24 +0200 Subject: [PATCH] ignore mass amount of results when picking for observation --- pkg/v3/plugin/hooks/add_from_staging.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/v3/plugin/hooks/add_from_staging.go b/pkg/v3/plugin/hooks/add_from_staging.go index 6655e016..630034ea 100644 --- a/pkg/v3/plugin/hooks/add_from_staging.go +++ b/pkg/v3/plugin/hooks/add_from_staging.go @@ -39,6 +39,12 @@ func (hook *AddFromStagingHook) RunHook(obs *ocr2keepersv3.AutomationObservation if err != nil { return err } + n := len(results) + maxResults := limit * 10 + if len(results) > maxResults { + hook.logger.Printf("too many results in staging (%d) ignoring %d results", n, len(results)-maxResults) + results = results[:maxResults] + } // creating a map to hold the shuffled workIDs shuffledIDs := make(map[string]string, len(results)) for _, result := range results { @@ -51,7 +57,7 @@ func (hook *AddFromStagingHook) RunHook(obs *ocr2keepersv3.AutomationObservation if len(results) > limit { results = results[:limit] } - hook.logger.Printf("adding %d results to observation", len(results)) + hook.logger.Printf("adding %d results to observation, out of %d available results", len(results), n) obs.Performable = append(obs.Performable, results...) return nil