From c791841595c04a30ae050454100fe5d45845afd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Fri, 7 Jul 2023 17:13:28 +0800 Subject: [PATCH] kube-ovn-controller: fix workqueue metrics (#3011) --- cmd/controller/controller.go | 4 ++-- go.mod | 2 +- pkg/controller/ovn_fip.go | 5 +++-- pkg/controller/ovn_snat.go | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index 15e7fa3bfec..15779a022c5 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -13,12 +13,12 @@ import ( v1 "k8s.io/api/authorization/v1" apiv1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apiserver/pkg/server" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/leaderelection" "k8s.io/client-go/tools/leaderelection/resourcelock" "k8s.io/client-go/tools/record" "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/manager/signals" kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" "github.com/kubeovn/kube-ovn/pkg/controller" @@ -35,7 +35,7 @@ func CmdMain() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { - stopCh := server.SetupSignalHandler() + stopCh := signals.SetupSignalHandler().Done() <-stopCh cancel() }() diff --git a/go.mod b/go.mod index e6b7df7aa6f..d6b34b29a66 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,6 @@ require ( gopkg.in/k8snetworkplumbingwg/multus-cni.v3 v3.9.2 k8s.io/api v0.26.6 k8s.io/apimachinery v0.26.6 - k8s.io/apiserver v0.26.6 k8s.io/client-go v12.0.0+incompatible k8s.io/klog/v2 v2.100.1 k8s.io/kubernetes v1.26.6 @@ -236,6 +235,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.26.6 // indirect + k8s.io/apiserver v0.26.6 // indirect k8s.io/cloud-provider v0.26.6 // indirect k8s.io/cluster-bootstrap v0.26.6 // indirect k8s.io/component-base v0.26.6 // indirect diff --git a/pkg/controller/ovn_fip.go b/pkg/controller/ovn_fip.go index a42e142cae8..cd59c86e697 100644 --- a/pkg/controller/ovn_fip.go +++ b/pkg/controller/ovn_fip.go @@ -5,8 +5,6 @@ import ( "encoding/json" "fmt" - kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" - "github.com/kubeovn/kube-ovn/pkg/util" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -14,6 +12,9 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "github.com/kubeovn/kube-ovn/pkg/util" ) func (c *Controller) enqueueAddOvnFip(obj interface{}) { diff --git a/pkg/controller/ovn_snat.go b/pkg/controller/ovn_snat.go index 020160aacc9..7a5c47e358e 100644 --- a/pkg/controller/ovn_snat.go +++ b/pkg/controller/ovn_snat.go @@ -5,8 +5,6 @@ import ( "encoding/json" "fmt" - kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" - "github.com/kubeovn/kube-ovn/pkg/util" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -14,6 +12,9 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "github.com/kubeovn/kube-ovn/pkg/util" ) func (c *Controller) enqueueAddOvnSnatRule(obj interface{}) {