From e8b5781499dfb35809c4ede091fc9718f142265e Mon Sep 17 00:00:00 2001 From: David Eads Date: Tue, 3 Sep 2019 11:22:56 -0400 Subject: [PATCH] add identification for particular certificate controllers --- cmd/kube-controller-manager/app/certificates.go | 2 ++ pkg/controller/certificates/approver/sarapprove.go | 1 + pkg/controller/certificates/certificate_controller.go | 11 ++++++++--- .../certificates/certificate_controller_test.go | 1 + pkg/controller/certificates/signer/cfssl_signer.go | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/kube-controller-manager/app/certificates.go b/cmd/kube-controller-manager/app/certificates.go index 3ecf69e395f..16708d726c2 100644 --- a/cmd/kube-controller-manager/app/certificates.go +++ b/cmd/kube-controller-manager/app/certificates.go @@ -45,6 +45,7 @@ func startCSRSigningController(ctx ControllerContext) (http.Handler, bool, error return nil, false, nil } if ctx.ComponentConfig.CSRSigningController.ClusterSigningCertFile == "" || ctx.ComponentConfig.CSRSigningController.ClusterSigningKeyFile == "" { + klog.V(2).Info("skipping CSR signer controller because no csr cert/key was specified") return nil, false, nil } @@ -79,6 +80,7 @@ func startCSRSigningController(ctx ControllerContext) (http.Handler, bool, error // setting up the signing controller. This isn't // actually a problem since the signer is not a // required controller. + klog.V(2).Info("skipping CSR signer controller because no csr cert/key was specified and the default files are missing") return nil, false, nil default: // Note that '!filesExist && !usesDefaults' is obviously diff --git a/pkg/controller/certificates/approver/sarapprove.go b/pkg/controller/certificates/approver/sarapprove.go index 42dff1d31b9..58b497755eb 100644 --- a/pkg/controller/certificates/approver/sarapprove.go +++ b/pkg/controller/certificates/approver/sarapprove.go @@ -49,6 +49,7 @@ func NewCSRApprovingController(client clientset.Interface, csrInformer certifica recognizers: recognizers(), } return certificates.NewCertificateController( + "csrapproving", client, csrInformer, approver.handle, diff --git a/pkg/controller/certificates/certificate_controller.go b/pkg/controller/certificates/certificate_controller.go index 36698cb036e..962180fe130 100644 --- a/pkg/controller/certificates/certificate_controller.go +++ b/pkg/controller/certificates/certificate_controller.go @@ -40,6 +40,9 @@ import ( ) type CertificateController struct { + // name is an identifier for this particular controller instance. + name string + kubeClient clientset.Interface csrLister certificateslisters.CertificateSigningRequestLister @@ -51,6 +54,7 @@ type CertificateController struct { } func NewCertificateController( + name string, kubeClient clientset.Interface, csrInformer certificatesinformers.CertificateSigningRequestInformer, handler func(*certificates.CertificateSigningRequest) error, @@ -61,6 +65,7 @@ func NewCertificateController( eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")}) cc := &CertificateController{ + name: name, kubeClient: kubeClient, queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewMaxOfRateLimiter( workqueue.NewItemExponentialFailureRateLimiter(200*time.Millisecond, 1000*time.Second), @@ -110,10 +115,10 @@ func (cc *CertificateController) Run(workers int, stopCh <-chan struct{}) { defer utilruntime.HandleCrash() defer cc.queue.ShutDown() - klog.Infof("Starting certificate controller") - defer klog.Infof("Shutting down certificate controller") + klog.Infof("Starting certificate controller %q", cc.name) + defer klog.Infof("Shutting down certificate controller %q", cc.name) - if !cache.WaitForNamedCacheSync("certificate", stopCh, cc.csrsSynced) { + if !cache.WaitForNamedCacheSync(fmt.Sprintf("certificate-%s", cc.name), stopCh, cc.csrsSynced) { return } diff --git a/pkg/controller/certificates/certificate_controller_test.go b/pkg/controller/certificates/certificate_controller_test.go index daf4689a42e..566e8d05351 100644 --- a/pkg/controller/certificates/certificate_controller_test.go +++ b/pkg/controller/certificates/certificate_controller_test.go @@ -55,6 +55,7 @@ func TestCertificateController(t *testing.T) { } controller := NewCertificateController( + "test", client, informerFactory.Certificates().V1beta1().CertificateSigningRequests(), handler, diff --git a/pkg/controller/certificates/signer/cfssl_signer.go b/pkg/controller/certificates/signer/cfssl_signer.go index 3ea3ca22e51..eab7e8a939c 100644 --- a/pkg/controller/certificates/signer/cfssl_signer.go +++ b/pkg/controller/certificates/signer/cfssl_signer.go @@ -47,6 +47,7 @@ func NewCSRSigningController( return nil, err } return certificates.NewCertificateController( + "csrsigning", client, csrInformer, signer.handle,