Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2fd3c490
Commit
2fd3c490
authored
Sep 18, 2016
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
controller: a couple of fixes for csr
Fixes: * delete resource handler wasn't taking into account tombstones * csr would requeue twice on update failure
parent
4b5c74ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
controller.go
pkg/controller/certificates/controller.go
+16
-17
No files found.
pkg/controller/certificates/controller.go
View file @
2fd3c490
...
@@ -49,9 +49,7 @@ type CertificateController struct {
...
@@ -49,9 +49,7 @@ type CertificateController struct {
csrController
*
cache
.
Controller
csrController
*
cache
.
Controller
csrStore
cache
.
StoreToCertificateRequestLister
csrStore
cache
.
StoreToCertificateRequestLister
// To allow injection of updateCertificateRequestStatus for testing.
syncHandler
func
(
csrKey
string
)
error
updateHandler
func
(
csr
*
certificates
.
CertificateSigningRequest
)
error
syncHandler
func
(
csrKey
string
)
error
approveAllKubeletCSRsForGroup
string
approveAllKubeletCSRsForGroup
string
...
@@ -107,7 +105,19 @@ func NewCertificateController(kubeClient clientset.Interface, syncPeriod time.Du
...
@@ -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{}) {
...
@@ -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 {
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment