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

Determine credential type from label #4825

Merged
merged 5 commits into from
Oct 19, 2023
Merged

Determine credential type from label #4825

merged 5 commits into from
Oct 19, 2023

Conversation

rainest
Copy link
Contributor

@rainest rainest commented Oct 12, 2023

What this PR does / why we need it:

Adds a label alternative to the kongCredType Secret field. Setting konghq.com/credential: CREDTYPE is now equivalent to setting a kongCredType=CREDTYPE Secret field.

Which issue this PR fixes:

Fix #2502

Special notes for your reviewer:

#2502 (comment) contains a migration script that will eventually go in docs. There isn't a clear place in 3.x docs to stick an upgrade section, so #4854 to follow up. As a stopgap, the changelog links to the comment.

Adds new system, does not remove old system. Not sure we want to single release breaking change this; I think we can do the final removal after 3.0 unless we want to bundle as many breaking changes at once, even if they're larger ones that didn't previously have a deprecation period: #4853

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (2089f87) 77.7% compared to head (68533b3) 77.9%.
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #4825     +/-   ##
=======================================
+ Coverage   77.7%   77.9%   +0.2%     
=======================================
  Files        164     165      +1     
  Lines      18399   18455     +56     
=======================================
+ Hits       14298   14389     +91     
+ Misses      3281    3256     -25     
+ Partials     820     810     -10     
Files Coverage Δ
...ion/validation/consumers/credentials/validation.go 96.2% <100.0%> (+6.8%) ⬆️
internal/dataplane/parser/parser.go 92.6% <100.0%> (+2.6%) ⬆️
internal/util/credential.go 100.0% <100.0%> (ø)
internal/admission/handler.go 61.2% <0.0%> (ø)
internal/dataplane/kongstate/kongstate.go 83.0% <92.3%> (+2.8%) ⬆️

... and 13 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rainest rainest force-pushed the feat/label-secrets branch 3 times, most recently from 13dc7ee to 4fef47b Compare October 13, 2023 00:18
@rainest
Copy link
Contributor Author

rainest commented Oct 13, 2023

Observed a flake in https:/Kong/kubernetes-ingress-controller/actions/runs/6511654773/attempts/1?pr=4825 but Github isn't showing any artifacts in the summary 😢

2023-10-13T18:32:19.8431950Z     translation_failures_test.go:287: received event's message (failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)) does not contain the expected reason: 'failed to construct certificate from secret'
2023-10-13T18:32:19.8456195Z     translation_failures_test.go:306: waiting for events, received so far:
2023-10-13T18:32:19.8458524Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)"
2023-10-13T18:32:19.8460802Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to construct certificate from secret"
2023-10-13T18:32:19.8462572Z         * Secret/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2: "failed to construct certificate from secret"
2023-10-13T18:32:20.8435119Z     translation_failures_test.go:287: received event's message (failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)) does not contain the expected reason: 'failed to construct certificate from secret'
2023-10-13T18:32:20.8456966Z     translation_failures_test.go:306: waiting for events, received so far:
2023-10-13T18:32:20.8459510Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)"
2023-10-13T18:32:20.8461884Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to construct certificate from secret"
2023-10-13T18:32:20.8463723Z         * Secret/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2: "failed to construct certificate from secret"
2023-10-13T18:32:21.8396897Z     translation_failures_test.go:261: 
2023-10-13T18:32:21.8398816Z         	Error Trace:	/home/runner/work/kubernetes-ingress-controller/kubernetes-ingress-controller/test/integration/translation_failures_test.go:261
2023-10-13T18:32:21.8400316Z         	Error:      	Condition never satisfied
2023-10-13T18:32:21.8401419Z         	Test:       	TestTranslationFailures/ingress_referring_a_secret_with_no_valid_TLS_key-pair

@rainest rainest marked this pull request as ready for review October 13, 2023 22:37
@rainest rainest requested a review from a team as a code owner October 13, 2023 22:37
internal/admission/handler.go Outdated Show resolved Hide resolved
internal/dataplane/kongstate/kongstate.go Outdated Show resolved Hide resolved
internal/dataplane/kongstate/kongstate.go Outdated Show resolved Hide resolved
@pmalek
Copy link
Member

pmalek commented Oct 17, 2023

Observed a flake in https:/Kong/kubernetes-ingress-controller/actions/runs/6511654773/attempts/1?pr=4825 but Github isn't showing any artifacts in the summary 😢

2023-10-13T18:32:19.8431950Z     translation_failures_test.go:287: received event's message (failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)) does not contain the expected reason: 'failed to construct certificate from secret'
2023-10-13T18:32:19.8456195Z     translation_failures_test.go:306: waiting for events, received so far:
2023-10-13T18:32:19.8458524Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)"
2023-10-13T18:32:19.8460802Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to construct certificate from secret"
2023-10-13T18:32:19.8462572Z         * Secret/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2: "failed to construct certificate from secret"
2023-10-13T18:32:20.8435119Z     translation_failures_test.go:287: received event's message (failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)) does not contain the expected reason: 'failed to construct certificate from secret'
2023-10-13T18:32:20.8456966Z     translation_failures_test.go:306: waiting for events, received so far:
2023-10-13T18:32:20.8459510Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to fetch the secret (f5538e3a-6211-440e-bcbd-3650432100a6/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2)"
2023-10-13T18:32:20.8461884Z         * Ingress/translation-failures-c86b6152-5e04-4aed-bdbe-bda6254336fc: "failed to construct certificate from secret"
2023-10-13T18:32:20.8463723Z         * Secret/translation-failures-d45b20b5-31e4-40fa-8fd2-e48520d3d0b2: "failed to construct certificate from secret"
2023-10-13T18:32:21.8396897Z     translation_failures_test.go:261: 
2023-10-13T18:32:21.8398816Z         	Error Trace:	/home/runner/work/kubernetes-ingress-controller/kubernetes-ingress-controller/test/integration/translation_failures_test.go:261
2023-10-13T18:32:21.8400316Z         	Error:      	Condition never satisfied
2023-10-13T18:32:21.8401419Z         	Test:       	TestTranslationFailures/ingress_referring_a_secret_with_no_valid_TLS_key-pair

Should be fixed by #4871

CHANGELOG.md Outdated Show resolved Hide resolved
@czeslavo czeslavo merged commit 1ceb6a8 into main Oct 19, 2023
35 checks passed
@czeslavo czeslavo deleted the feat/label-secrets branch October 19, 2023 09:12
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
@pmalek pmalek added this to the KIC v3.0.0 milestone Oct 19, 2023
czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
credential type instead of the `kongCredType` field. This allows controller
compontents to avoid caching unnecessary Secrets. The `kongCredType` field is
still supported but is now deprecated. A script to generate commands to
update Secrets is available at https:/Kong/kubernetes-ingress-controller/issues/2502#issuecomment-1758213596
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we track changing this changelog entry to reference a proper docs link (or an equivalent) rather than a github issue link

czeslavo added a commit to czeslavo/kubernetes-ingress-controller that referenced this pull request Oct 19, 2023
* feat(credentials) accept label credential type

* pr: remove bad copy/paste resource failure

* pr: reuse credential type code and add unit

* pr: log instead of failure, align test with new error

* use correct label in changelog

---------

Co-authored-by: Grzegorz Burzyński <[email protected]>
@pmalek
Copy link
Member

pmalek commented Oct 19, 2023

I'd assume we need to add validation to webhook to check secrets with the introduced label? (so that eventually we'd only check those instead of inspecting fields?)

@czeslavo
Copy link
Contributor

I'd assume we need to add validation to webhook to check secrets with the introduced label? (so that eventually we'd only check those instead of inspecting fields?)

Yeah, that should do the job: #4896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change kongCredType to a label
3 participants