From f90245403d312a37e383224102afba4afe20df0e Mon Sep 17 00:00:00 2001 From: Oilbeater Date: Mon, 21 Nov 2022 13:32:16 +0800 Subject: [PATCH] perf: reduce controller init time (#2054) Controller always sleeps 8 seconds before processing, reducing the sleep time. (cherry picked from commit db4fd629032d6e4406ce3e017178f7321a601265) --- pkg/controller/election.go | 2 +- pkg/controller/gc.go | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/controller/election.go b/pkg/controller/election.go index c68c9a0b940..ab6effffa39 100644 --- a/pkg/controller/election.go +++ b/pkg/controller/election.go @@ -56,7 +56,7 @@ func (c *Controller) leaderElection() { klog.Info("waiting for becoming a leader") flag = true } - time.Sleep(5 * time.Second) + time.Sleep(1 * time.Second) } } diff --git a/pkg/controller/gc.go b/pkg/controller/gc.go index 12e543661ef..49a2455cadc 100644 --- a/pkg/controller/gc.go +++ b/pkg/controller/gc.go @@ -3,15 +3,13 @@ package controller import ( "context" "fmt" - "strings" - "time" - corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" + "strings" kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" "github.com/kubeovn/kube-ovn/pkg/ovs" @@ -219,7 +217,6 @@ func (c *Controller) gcLogicalSwitchPort() error { if err := c.markAndCleanLSP(); err != nil { return err } - time.Sleep(3 * time.Second) return c.markAndCleanLSP() }