Skip to content

Conversation

randmonkey
Copy link
Contributor

@randmonkey randmonkey commented Jun 25, 2025

What this PR does / why we need it:

When KongUpstreamPolicy set algorithm to sticky-sessions and Kong gateway version < 3.11, generate a KongConfigurationTranslationFailed event for services using the KongUpstreamPolicy and do not override translated upstream by KongUpstreamPolicy.

Which issue this PR fixes:

closes #7537

Special notes for your reviewer:

Generation of event for Kong Gateway < 3.11.0 is covered by dedicated envtest TestStickySessionsNotSupportedEventGeneration. Big general envtest TestConfigErrorEventGenerationInMemoryMode to pass has to detect this event too, because 3.11.0 is not released yet, so there is no support. But 3.11.0 is around the corner, so when it is updated, this test will fail, and someone needs to adjust it as described in the TODO to cover the situation of not generating this event. There is rather no point in introducing some machinery for testing it now. Proper behavior has been tested manually with the release candidate of 3.11.0, so the update will go smoothly

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

@randmonkey randmonkey requested a review from a team as a code owner June 25, 2025 09:12
@randmonkey randmonkey marked this pull request as draft June 25, 2025 09:12
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.4%. Comparing base (4ee641e) to head (b6d72d6).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #7538     +/-   ##
=======================================
- Coverage   77.4%   77.4%   -0.1%     
=======================================
  Files        221     221             
  Lines      25573   25588     +15     
=======================================
+ Hits       19808   19818     +10     
- Misses      4755    4758      +3     
- Partials    1010    1012      +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tao12345666333
Copy link
Member

I believe there are two points that need to be addressed here: in addition to not supporting the sticky-sessions algorithm, it is also necessary to check that setting the stickySessions.cookie and stickySession.cookie_path fields in KongUpstreamPolicy is not allowed.

Of course, for the checks on the last two fields, we might be able to avoid them through a CEL rule.

https://github.com/Kong/kubernetes-configuration/blob/5edaf967a41f5698156813a8a27fa7ecacb9f33e/api/configuration/v1beta1/kongupstreampolicy_types.go#L44-L56

@pmalek
Copy link
Member

pmalek commented Jun 25, 2025

I believe there are two points that need to be addressed here: in addition to not supporting the sticky-sessions algorithm, it is also necessary to check that setting the stickySessions.cookie and stickySession.cookie_path fields in KongUpstreamPolicy is not allowed.

Of course, for the checks on the last two fields, we might be able to avoid them through a CEL rule.

https://github.com/Kong/kubernetes-configuration/blob/5edaf967a41f5698156813a8a27fa7ecacb9f33e/api/configuration/v1beta1/kongupstreampolicy_types.go#L44-L56

AFAICT we can't use CEL for these because we don't know the Kong version used in the CEL context. We only know it in runtime.

@tao12345666333
Copy link
Member

You are right. @pmalek

However, I also submitted a PR to add a CEL rule for it. I will be unavailable for the next few days, so if you think it's valuable, you can merge that PR as well.
Kong/kubernetes-configuration#472

@programmer04 programmer04 self-assigned this Jun 25, 2025
@programmer04 programmer04 added this to the KIC v3.5.x milestone Jun 25, 2025
@programmer04 programmer04 force-pushed the feat/check_kong_version_sticky_sessions branch 2 times, most recently from 03fca2e to bdfeb73 Compare June 26, 2025 12:37
@programmer04 programmer04 force-pushed the feat/check_kong_version_sticky_sessions branch 4 times, most recently from 2e6b5c7 to 91e9a00 Compare June 27, 2025 17:27
@programmer04 programmer04 marked this pull request as ready for review June 27, 2025 17:27
@programmer04 programmer04 enabled auto-merge June 27, 2025 17:46
tao12345666333
tao12345666333 previously approved these changes Jun 30, 2025
@programmer04 programmer04 added this pull request to the merge queue Jun 30, 2025
@programmer04 programmer04 removed this pull request from the merge queue due to a manual request Jun 30, 2025
@programmer04 programmer04 force-pushed the feat/check_kong_version_sticky_sessions branch from cca4cad to b6d72d6 Compare June 30, 2025 08:03
@programmer04 programmer04 enabled auto-merge June 30, 2025 08:04
@programmer04 programmer04 added this pull request to the merge queue Jun 30, 2025
@tao12345666333 tao12345666333 mentioned this pull request Jun 30, 2025
36 tasks
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 30, 2025
@programmer04 programmer04 added this pull request to the merge queue Jun 30, 2025
Merged via the queue into main with commit dd6538b Jun 30, 2025
42 checks passed
@programmer04 programmer04 deleted the feat/check_kong_version_sticky_sessions branch June 30, 2025 09:37
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.

Check Kong version for generating sticky session algorithm for upstreams
4 participants