From 8264618247db5f3ac1b65f5174dca45d9df958d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Golicz?= Date: Fri, 25 Oct 2024 10:51:05 +0200 Subject: [PATCH] remove periodical sync of Runtime metrics --- cmd/main.go | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 6a20c069..e613ec4e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -69,7 +69,6 @@ const defaultExpirationTime = 24 * time.Hour const defaultGardenerRequestTimeout = 60 * time.Second const defaultControlPlaneRequeueDuration = 10 * time.Second const defaultGardenerRequeueDuration = 15 * time.Second -const RuntimeMetricRefreshPeriod = 30 * time.Second func main() { var metricsAddr string @@ -221,30 +220,20 @@ func main() { os.Exit(1) } - refreshRuntimeMetrics := func() { - logger.Info("Refreshing runtime CR metrics") - metrics.ResetRuntimeMetrics() - var RuntimeList infrastructuremanagerv1.RuntimeList - if err = mgr.GetClient().List(context.TODO(), &RuntimeList); err == nil { - for _, rt := range RuntimeList.Items { - metrics.SetRuntimeStates(rt) - } + logger.Info("Refreshing runtime CR metrics") + metrics.ResetRuntimeMetrics() + var RuntimeList infrastructuremanagerv1.RuntimeList + if err = mgr.GetClient().List(context.TODO(), &RuntimeList); err == nil { + for _, rt := range RuntimeList.Items { + metrics.SetRuntimeStates(rt) } } - quitChannel := startRuntimeMetricsRefresher(refreshRuntimeMetrics) - defer func() { - logger.Info("Stopping metric refresh process goroutine") - if quitChannel != nil { - quitChannel <- true - } - }() - setupLog.Info("Starting Manager", "kubeconfigExpirationTime", expirationTime, "kubeconfigRotationPeriod", rotationPeriod) if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager") - os.Exit(1) //nolint:gocritic + os.Exit(1) } } @@ -324,20 +313,3 @@ func validateAuditLogDataMap(data map[string]map[string]auditlogging.AuditLogDat return nil } - -func startRuntimeMetricsRefresher(refreshFunc func()) chan bool { - quitChannel := make(chan bool) - go func() { - for { - time.Sleep(RuntimeMetricRefreshPeriod) - select { - case <-quitChannel: - // println("Received signal to stop metric refresh process") - return - default: - refreshFunc() - } - } - }() - return quitChannel -}