Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Certificates over CertificateRequests (#55 followup) #101

Merged

Conversation

SgtCoDFish
Copy link
Member

@SgtCoDFish SgtCoDFish commented Sep 30, 2024

@jacksgt made an excellent start to this in #55 and I've preserved their authorship on the commit.

This PR adds a few followup changes to resolve merge conflicts, ensure tests pass and to improve behaviour locally.

From testing in Kind, I've confirmed that this PR does create and update certificates, and that if a secret already exists when a route is reconciled that secret will be picked up.

This is a WIP PR - to make the tests work I deleted a lot fo code, but there are probably useful tests we can perform for Certs which are similar to those we deleted.

UPDATE: We've now decided that we'll take this approach over the approach in #102 so I'll fix up this PR to get it ready for review.

@cert-manager-prow cert-manager-prow bot added the dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. label Sep 30, 2024
@SgtCoDFish SgtCoDFish changed the title Use Certificates over CertificateRequests ( Use Certificates over CertificateRequests (#55 followup) Sep 30, 2024
@cert-manager-prow cert-manager-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 30, 2024
@SgtCoDFish
Copy link
Member Author

SgtCoDFish commented Sep 30, 2024

/hold

EDIT: This hold was while this was WIP. It's now ready for review so I'll unhold.

@cert-manager-prow cert-manager-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 30, 2024
@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from f6482a7 to c0b0dd6 Compare September 30, 2024 15:38
internal/controller/sync.go Outdated Show resolved Hide resolved
internal/controller/sync.go Outdated Show resolved Hide resolved
@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from fa0ac3f to 702e517 Compare October 1, 2024 17:30
@SgtCoDFish
Copy link
Member Author

/unhold

@cert-manager-prow cert-manager-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 2, 2024
As discussed in
cert-manager#49 ,
using `CertificateRequest` resources for interacting with cert-manager
has several drawbacks:

- this project (openshift-routes) has to duplicate logic for handling
the creation of certificates that already exists in cert-manager.
- observability is impaired because cert-manager does not offer
metrics for `CertificateRequest` resources, only for `Certificates`.

Therefore, this patch replaces the management of `CertificateRequests` with
`Certificates` (and `Secrets`). In return, it requires slightly higher
privileges because openshift-routes needs to be able to
create and read `Certificates`.
At the same time, the code complexity and LOC has been reduced.

Signed-off-by: Jack Henschel <[email protected]>
@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from 9058138 to d22d991 Compare October 2, 2024 09:17
@cert-manager-prow cert-manager-prow bot added dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. and removed dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Oct 2, 2024
@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from d22d991 to 88600f5 Compare October 2, 2024 09:32
@cert-manager-prow cert-manager-prow bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. and removed dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. labels Oct 2, 2024
internal/controller/sync.go Outdated Show resolved Hide resolved
internal/controller/sync.go Outdated Show resolved Hide resolved
@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from 39213bb to 5b2d427 Compare October 2, 2024 17:38
return strconv.Atoi(revision)
}
func (r *RouteController) getCertificateForRoute(ctx context.Context, route *routev1.Route) (*cmapi.Certificate, error) {
// Note: this could also implement logic to re-use an existing certificate: route.Annotations[cmapi.CertificateNameKey]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that it isn't possible (yet) to pre-create a Certificate in order to use a Certificate field that isn't supported using Route annotations?

(mentioned by @ctrought in #49 (comment))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct as far as I know yeah. That sounds like a nice-to-have rather than a need-to-have; do you agree?

I think a more pressing need is what was briefly discussed in standup yesterday, which is that this logic mirrors so much about ingress-shim that we could expose the ingress-shim logic from cert-manager and re-use it here. But I didn't want to bite off a cert-manager change here.

Something like (pseudo function) cmingress.AnnotationsToCertificate(...).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, let's postpone this to later (if folks still need it).

this logic mirrors so much about ingress-shim that we could expose the ingress-shim

It would be great if we could do that, especially since we aim to support all the same annotations.

Is it possible do this this now (with no work needed on the cert-manager project), or does it require changes in the cert-manager project in which case we would probably be better off doing that in the next release of openshift-routes?

internal/controller/sync.go Outdated Show resolved Hide resolved
Copy link
Member

@maelvls maelvls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey. I went over the code and found it well written and nothing stood out as an issue.

During my review, I haven't gone over the updated unit tests, I haven't run the ./test-smoke.sh myself, and haven't run openshift-routes locally to test it out... Hoping that it all works 😅

@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from 128c291 to a994911 Compare October 3, 2024 09:32
The main aim here is to improve testing and to add other annotations
that weren't added in the open source PR.

This is a squashed commit of several:

- ensure logr calls have named args to prevent panics
- update RBAC to use certs rather than certreqs
- fix duration in smoke test, log when polling
- don't try to create secret, clean up tests
- fix lint error, allow more permissive algorithm specification
- change check for CRs to certs
- don't Own Secrets since we don't generate them
- add support for IP addresses + URIs for certs
- add most remaining annotations and improve integration/e2e tests
- remove readme notice
- remove create secrets permission
- ensure deterministic cert name + check names aren't too long
- Review comments from Mael: A grammar fix + context on
  IngressController

Signed-off-by: Ashley Davis <[email protected]>
@SgtCoDFish SgtCoDFish force-pushed the jacksgt-use-certificates branch from a994911 to b55e587 Compare October 3, 2024 09:57
Copy link
Member

@maelvls maelvls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have had a chat this morning and we would like to have this released by tomorrow. I haven't performed additional tests, but I trust Ash's word: Ash is confident enough thanks to the smoke tests and the testing he has done.

Approved!

@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maelvls

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2024
@maelvls
Copy link
Member

maelvls commented Oct 3, 2024

/lgtm
/hold in case Tim wants to do a review

@cert-manager-prow cert-manager-prow bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Oct 3, 2024
@inteon
Copy link
Member

inteon commented Oct 3, 2024

I reviewed the code and the smoke test is passing.
So this PR is good-to-go for me.
/unhold

@cert-manager-prow cert-manager-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 3, 2024
@cert-manager-prow cert-manager-prow bot merged commit e8a79cc into cert-manager:main Oct 3, 2024
5 checks passed
@SgtCoDFish SgtCoDFish deleted the jacksgt-use-certificates branch October 3, 2024 12:17
@jacksgt
Copy link
Contributor

jacksgt commented Oct 4, 2024

Hi @SgtCoDFish , thanks for picking this up and all of your work around getting it ready to be shipped - amazing progress!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants