Repository navigation
ingress-shim: untangle logic for "looking for cert owners" - #4149
Conversation
bd69fdc to
bc8b7cf
Compare
687b63c to
23fce3d
Compare
23fce3d to
0dd4309
Compare
Signed-off-by: Maël Valais <[email protected]>
0dd4309 to
75b9bd6
Compare
|
@irbekrm I added a couple of comments to help the review process 😅 |
|
I just noticed there is 0 unit test around |
|
[I just read the description, not the code] The first obvious question to me is whether we set the ingress as the owner of the cert The second thing I noticed is that the previous code could find multiple ingresses, |
That's a good question, I assumed that it was the case. Looking at the creation of the Certificate "shim", it seems like we always do add the Ingress as an owner (and more specifically, a "controller object", which is an ownerReference with
Each Certificate can only be owned by a single Ingress, but one Ingress can be associated with multiple Certificate (which is fine). Just to elaborate further, the old code relied solely on the The new code uses the I can't think of any reason for not using |
|
/assign @maelvls |
|
Good explanation, thanks. |
Signed-off-by: Maël Valais <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
05378ab to
30ad337
Compare
|
/test pull-cert-manager-bazel |
cf6f7e5 to
4759995
Compare
Signed-off-by: Maël Valais <[email protected]>
Signed-off-by: Maël Valais <[email protected]>
3b165c4 to
67b48fb
Compare
|
I added unit tests around
Doing so, I discovered that we did not only re-queue the parent ingress on the deletion of its child certificate, but also on creation and update. |
The func certificateDeleted was being called on every possible event (deleted, created, updated). Signed-off-by: Maël Valais <[email protected]>
3a48870 to
570c81e
Compare
irbekrm
left a comment
There was a problem hiding this comment.
This looks good to me as we already reviewed it together.
I've added a couple more questions, but happy to merge once the tests pass.
Thanks for adding the test cases- it also helps with understanding what the code is doing!
570c81e to
5d34571
Compare
5d34571 to
a7b2c25
Compare
Signed-off-by: Maël Valais <[email protected]> Co-authored-by: Irbe Krumina <[email protected]>
a7b2c25 to
b13b751
Compare
| for { | ||
| // Get blocks until either (1) a key is returned, or (2) the | ||
| // queue is shut down. | ||
| gotKey, done := queue.Get() | ||
| if done { | ||
| break | ||
| } | ||
| gotKeys = append(gotKeys, gotKey.(string)) | ||
| } |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: irbekrm, maelvls The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
DNS- this is a known issue in the workers cluster |
|
/retest |
While thinking about James's #4121 (comment), I came across a weirdness in the ingress-shim controller.
Anytime a Certificate is deleted, we want to trigger a resync of the Ingress that owns this Certificate. Let's imagine that the below Certificate gets deleted:
The
certificateDeletedwants to trigger a resync of the Ingressexampleon the same namespacefoo.But for some reason,
certificateDeleteddoes way more than just looking at the owner reference: it calls toingressesForCertificatewhich lists all the Ingresses (even outside of the Certificate's namespace).(Note: I simplified a bit the code)
Why do we need to loop over the ingresses? We are not even filtering on the Certificate's namespace, which means we need to iterate over all Ingresses that exist on the cluster every time a Certificate gets an update.
Why not just look at the Certificate's owner references and trigger a "requeue" based on that? I am trying to find a security risk associated with that, but I can't find one.
It could look like this:
Pros:
Cons:
ownerReferencedoes not exist (in which case this Certificate should have been garbage-collected anyway), then theingress.Syncwill say that this Ingress does not exist.Note that I also chose to avoid using the
controllerstruct as a receiver, since it obfuscates what this function depends on. If this function was depending on a lister, we would like to see that immediately.Before:
After:
/kind cleanup
/area ingress-shim
/cc @munnerz