Merge pull request #82279 from deads2k/which-cert

add identification for particular certificate controllers
This commit is contained in:
Kubernetes Prow Robot 2019-09-11 15:25:00 -07:00 committed by GitHub
commit 1146e0c4ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -49,6 +49,7 @@ func NewCSRApprovingController(client clientset.Interface, csrInformer certifica
recognizers: recognizers(),
}
return certificates.NewCertificateController(
"csrapproving",
client,
csrInformer,
approver.handle,

View File

@ -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
}

View File

@ -55,6 +55,7 @@ func TestCertificateController(t *testing.T) {
}
controller := NewCertificateController(
"test",
client,
informerFactory.Certificates().V1beta1().CertificateSigningRequests(),
handler,

View File

@ -47,6 +47,7 @@ func NewCSRSigningController(
return nil, err
}
return certificates.NewCertificateController(
"csrsigning",
client,
csrInformer,
signer.handle,