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

fix: don't error if source selector selects no sources #432

Merged

Conversation

erikgb
Copy link
Contributor

@erikgb erikgb commented Sep 9, 2024

Fixes #426?

We have a test that asserts an error when the bundle is empty. I doubt if this is correct, and to fix #426 properly, I think this behavior must go. We could eventually assert that a Bundle is invalid if it doesn't contain at least one source spec. But that is better done with the webhook (or API CEL expression) IMO.

UPDATE: After discussing this PR in today's stand-up, we decided to keep the existing (and tested) behavior where a target bundle needs to contain at least one certificate, at least for now. This means that this PR only fixes a minor bug: before this PR it would error if any source selector selects no sources. Now this is ok, but the resulting bundle must contain at least one certificate.

@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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 9, 2024
@erikgb
Copy link
Contributor Author

erikgb commented Sep 9, 2024

/cc @SgtCoDFish

@erikgb erikgb force-pushed the fix-non-matching-source-selector branch 2 times, most recently from 59c12c5 to 3ec505e Compare September 10, 2024 10:53
@cert-manager-prow cert-manager-prow bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 10, 2024
@erikgb
Copy link
Contributor Author

erikgb commented Sep 10, 2024

@SgtCoDFish I think this PR is ready for another review now!

Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

One suggestion from me; what do you think?

Signed-off-by: Erik Godding Boye <egboye@gmail.com>
@erikgb erikgb force-pushed the fix-non-matching-source-selector branch from 3ec505e to e7049f0 Compare September 10, 2024 17:06
@cert-manager-prow cert-manager-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 10, 2024
Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

I'm not sure if I missed something but wasn't there a new check to ensure the bundle wasn't empty, so we still required a bundle to resolve to at least one cert?

Is that missing here? Was it added elsewhere? I might be missing it but it looks like this would permit an empty target?

@erikgb
Copy link
Contributor Author

erikgb commented Sep 11, 2024

I'm not sure if I missed something but wasn't there a new check to ensure the bundle wasn't empty, so we still required a bundle to resolve to at least one cert?

Is that missing here? Was it added elsewhere? I might be missing it but it looks like this would permit an empty target?

The check is already there: https://github.com/cert-manager/trust-manager/blob/main/pkg/bundle/source.go#L90-L92, and it is now not changed in this PR. 😉 Tested by an existing test, but also with one of the additional tests introduced in this PR (selects nothing).

Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Sorry for the delay, something came up!

I totally missed that check. Thanks very much for this 🙌

@cert-manager-prow cert-manager-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 11, 2024
@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

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 Sep 11, 2024
@cert-manager-prow cert-manager-prow bot merged commit 94e1ed6 into cert-manager:main Sep 11, 2024
6 checks passed
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not throw error when matchLabels do not find any secret/configmap
2 participants