From fa885dfa0086f614c2eab02832940f924f4917bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Fri, 10 Mar 2023 14:52:48 +0100 Subject: [PATCH] fix: improve reports controller default values and workers (cherry-pick #6522) (#6532) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: improve reports controller default values and workers (#6522) * fix: improve reports controller default values and worker Signed-off-by: Charles-Edouard Brétéché * fix Signed-off-by: Charles-Edouard Brétéché * fix Signed-off-by: Charles-Edouard Brétéché * nits Signed-off-by: Charles-Edouard Brétéché --------- Signed-off-by: Charles-Edouard Brétéché * default qps Signed-off-by: Charles-Edouard Brétéché --------- Signed-off-by: Charles-Edouard Brétéché --- cmd/internal/flag.go | 4 ++-- pkg/controllers/report/admission/controller.go | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/internal/flag.go b/cmd/internal/flag.go index 5ef19c4238..6b274e1c37 100644 --- a/cmd/internal/flag.go +++ b/cmd/internal/flag.go @@ -59,8 +59,8 @@ func initMetricsFlags() { func initKubeconfigFlags() { flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") - flag.Float64Var(&clientRateLimitQPS, "clientRateLimitQPS", 20, "Configure the maximum QPS to the Kubernetes API server from Kyverno. Uses the client default if zero.") - flag.IntVar(&clientRateLimitBurst, "clientRateLimitBurst", 50, "Configure the maximum burst for throttle. Uses the client default if zero.") + flag.Float64Var(&clientRateLimitQPS, "clientRateLimitQPS", 300, "Configure the maximum QPS to the Kubernetes API server from Kyverno. Uses the client default if zero.") + flag.IntVar(&clientRateLimitBurst, "clientRateLimitBurst", 100, "Configure the maximum burst for throttle. Uses the client default if zero.") } func InitFlags(config Configuration) { diff --git a/pkg/controllers/report/admission/controller.go b/pkg/controllers/report/admission/controller.go index 0c53ec1d62..8b593259e7 100644 --- a/pkg/controllers/report/admission/controller.go +++ b/pkg/controllers/report/admission/controller.go @@ -26,7 +26,7 @@ import ( const ( // Workers is the number of workers for this controller - Workers = 2 + Workers = 10 ControllerName = "admission-report-controller" maxRetries = 10 deletionGrace = time.Minute * 2 @@ -241,6 +241,7 @@ func (c *controller) reconcile(ctx context.Context, logger logr.Logger, key, _, if !found { return c.cleanupReports(ctx, "", "", reports...) } + quit := false // set orphan reports an owner for _, report := range reports { if len(report.GetOwnerReferences()) == 0 { @@ -249,10 +250,16 @@ func (c *controller) reconcile(ctx context.Context, logger logr.Logger, key, _, return err } controllerutils.SetOwner(report, gvk.GroupVersion().String(), gvk.Kind, resource.Name, uid) - _, err = reportutils.UpdateReport(ctx, report, c.client) - return err + if _, err = reportutils.UpdateReport(ctx, report, c.client); err != nil { + return err + } + quit = true } } + // if one report was updated we can quit, reconcile will be triggered again because uid was queued + if quit { + return nil + } // build an aggregated report return c.aggregateReports(ctx, uid, gvk, resource, reports...) }