mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #33001 from kargakis/fix-requeueing-in-csr-controller
Automatic merge from submit-queue controller: a couple of fixes for csr Fixes: * delete resource handler wasn't taking into account tombstones * csr would requeue twice on update failure @deads2k @mikedanese ptal
This commit is contained in:
commit
aa60583ea1
@ -49,8 +49,6 @@ type CertificateController struct {
|
|||||||
csrController *cache.Controller
|
csrController *cache.Controller
|
||||||
csrStore cache.StoreToCertificateRequestLister
|
csrStore cache.StoreToCertificateRequestLister
|
||||||
|
|
||||||
// To allow injection of updateCertificateRequestStatus for testing.
|
|
||||||
updateHandler func(csr *certificates.CertificateSigningRequest) error
|
|
||||||
syncHandler func(csrKey string) error
|
syncHandler func(csrKey string) error
|
||||||
|
|
||||||
approveAllKubeletCSRsForGroup string
|
approveAllKubeletCSRsForGroup string
|
||||||
@ -107,7 +105,19 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du
|
|||||||
cc.enqueueCertificateRequest(new)
|
cc.enqueueCertificateRequest(new)
|
||||||
},
|
},
|
||||||
DeleteFunc: func(obj interface{}) {
|
DeleteFunc: func(obj interface{}) {
|
||||||
csr := obj.(*certificates.CertificateSigningRequest)
|
csr, ok := obj.(*certificates.CertificateSigningRequest)
|
||||||
|
if !ok {
|
||||||
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
|
if !ok {
|
||||||
|
glog.V(2).Infof("Couldn't get object from tombstone %#v", obj)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
csr, ok = tombstone.Obj.(*certificates.CertificateSigningRequest)
|
||||||
|
if !ok {
|
||||||
|
glog.V(2).Infof("Tombstone contained object that is not a CSR: %#v", obj)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
glog.V(4).Infof("Deleting certificate request %s", csr.Name)
|
glog.V(4).Infof("Deleting certificate request %s", csr.Name)
|
||||||
cc.enqueueCertificateRequest(obj)
|
cc.enqueueCertificateRequest(obj)
|
||||||
},
|
},
|
||||||
@ -166,18 +176,6 @@ func (cc *CertificateController) enqueueCertificateRequest(obj interface{}) {
|
|||||||
cc.queue.Add(key)
|
cc.queue.Add(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *CertificateController) updateCertificateRequestStatus(csr *certificates.CertificateSigningRequest) error {
|
|
||||||
_, updateErr := cc.kubeClient.Certificates().CertificateSigningRequests().UpdateStatus(csr)
|
|
||||||
if updateErr == nil {
|
|
||||||
// success!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// retry on failure
|
|
||||||
cc.enqueueCertificateRequest(csr)
|
|
||||||
return updateErr
|
|
||||||
}
|
|
||||||
|
|
||||||
// maybeSignCertificate will inspect the certificate request and, if it has
|
// maybeSignCertificate will inspect the certificate request and, if it has
|
||||||
// been approved and meets policy expectations, generate an X509 cert using the
|
// been approved and meets policy expectations, generate an X509 cert using the
|
||||||
// cluster CA assets. If successful it will update the CSR approve subresource
|
// cluster CA assets. If successful it will update the CSR approve subresource
|
||||||
@ -217,7 +215,8 @@ func (cc *CertificateController) maybeSignCertificate(key string) error {
|
|||||||
csr.Status.Certificate = certBytes
|
csr.Status.Certificate = certBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
return cc.updateCertificateRequestStatus(csr)
|
_, err = cc.kubeClient.Certificates().CertificateSigningRequests().UpdateStatus(csr)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *CertificateController) maybeAutoApproveCSR(csr *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) {
|
func (cc *CertificateController) maybeAutoApproveCSR(csr *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user