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

[backport 3.5]feat(router/atc): http segments matching and other improvements #12397

Merged
merged 21 commits into from
Mar 7, 2024

Conversation

chronolaw
Copy link
Contributor

@chronolaw chronolaw commented Jan 23, 2024

Summary

KAG-3586

git cherry-pick 59670a1 #11721
git cherry-pick 5f5e272 #11904
git cherry-pick 6ce1262 #11905
git cherry-pick 12f45ad #11914
git cherry-pick 12f45ad #11948
git cherry-pick c9fd6c1 #12127
git cherry-pick 8c2b5a4 #12258
git cherry-pick 86f0a6c #12261, fixing *.test
git cherry-pick f49abd6 #12180, fixing *.test (https://github.com/Kong/kong/pull/12268/files#diff-50dcfdce82665f85d2027363af6956fc788e5b8f6c6b8de907e9bd82e8871501)
git cherry-pick 11d7639 #12266
git cherry-pick 560fdfb #11950
git cherry-pick ce12f68 #12307, fixing *.test
git cherry-pick 9305665 #12283
git cherry-pick ef87932 #12378

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix #[issue number]

@chronolaw chronolaw changed the title [cherry]feat(router/atc): http segments matching and other improvements [backport]feat(router/atc): http segments matching and other improvements Jan 23, 2024
@chronolaw chronolaw changed the title [backport]feat(router/atc): http segments matching and other improvements [backport 3.5]feat(router/atc): http segments matching and other improvements Jan 24, 2024
@chronolaw chronolaw marked this pull request as ready for review January 27, 2024 01:20
@chronolaw chronolaw force-pushed the cherry/http_segments_matching_35 branch from 5c96d34 to 0b38029 Compare February 26, 2024 02:27
Copy link
Contributor

@nowNick nowNick left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀

I double checked commits & PRs so I don't have any other comments than those described here: #12400 (review)

@chobits
Copy link
Contributor

chobits commented Mar 1, 2024

I have double checked PRs that need to be cherry-picked

TODO: I'll assist with running perf test on release/3.5.x after this PR is merged.

chronolaw and others added 14 commits March 5, 2024 15:13
…11721)

resty.core.utils.str_replace_char() is a better way to replace - to _.
In the future string.lua will gather more functions to simplify tools.utils.lua.

See: #10443
#11904)

This helps with generating easier to read expressions, and the code is more straightforward. However, we must fallback to the old style escaping if the value contains `"#` (very unlikely case).

KAG-2952
…pressions` flavor (#11905)

`traditional_compatible` flavor remains case insensitive to stay compatible with `traditional` flavor.

This change allow `expressions` route authors to pick whether they want case sensitive or insensitive matches.

KAG-2905

---------

Co-authored-by: Datong Sun <[email protected]>
…outer (#12127)

Cache key and context generation are closely related on field present inside configured expressions.

It is advantageous to unify the logic for generating them to:

1. Improve cache hit rate, so that only fields referenced inside expressions participates in cache
key generation. This is particularly important since we plan on adding more match fields into
expressions in the future
2. Improve performance, allows field value to be cached and reused between cache key and context generation
3. Reduced code duplication

KAG-3032
… new context (#12258)

To avoid frequent memory allocation/deallocations.

KAG-3448
Fix `03-http-log/01-log_spec.lua`
Fix `13-cors/01-access_spec.lua`
Fix `spec/03-plugins/03-http-log/01-log_spec.lua`
…expression routes (#11950)

These fields are available in stream (L4) routes, making them also available in HTTP to reduce discrepancy between HTTP and stream routes.

KAG-2963
KAG-3032
…ase of cache hits (#12307)

`upstream_uri` is dependent on request path, and should not be automatically cached inside the route cache due to potential for path matching not being configured inside routes.

KAG-3505
dndx and others added 7 commits March 5, 2024 15:13
Full changelog: https://github.com/Kong/atc-router/releases/tag/v1.5.1

This primarily contains the small Bazel change which reduced artifact size by 50%. Thanks @ADD-SP for the work.
This field represents how much segments the request path contains.

For example, "/a/b/c/" contains 3 segments, "/a" contains 1 and "/" contains 0 segment.

It is useful for implementing segment based routing logic such as these used in OpenAPI spec.

KAG-3604
…ot" operator support in ATC (#12405)

KAG-3605

---------

Co-authored-by: Datong Sun <[email protected]>
* perf(router): use static functions for callbacks

Signed-off-by: Aapo Talvensaari <[email protected]>

* tuning some code

* style clean

* style clean

* style clean

---------

Signed-off-by: Aapo Talvensaari <[email protected]>
Co-authored-by: chronolaw <[email protected]>
@locao locao force-pushed the cherry/http_segments_matching_35 branch from 0b38029 to 24480f4 Compare March 5, 2024 18:13
Copy link
Contributor

@StarlightIbuki StarlightIbuki left a comment

Choose a reason for hiding this comment

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

Since this is a backport, I'm OK with the change. Just leaving some comments about namings.

Copy link
Contributor

Choose a reason for hiding this comment

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

The naming is over-generized. The functions in it are just for conversion between naming conventions. Please consider renaming this file and the functions.
We cannot tell what the function does by its name: replace dashes for what?

Comment on lines +21 to +22
local PREFIX_LEN = 13 -- #"http.headers."
local HTTP_HEADERS_PREFIX = "http.headers."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
local PREFIX_LEN = 13 -- #"http.headers."
local HTTP_HEADERS_PREFIX = "http.headers."
local HTTP_HEADERS_PREFIX = "http.headers."
local PREFIX_LEN = #"http.headers."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I will do it later.

@@ -19,8 +24,35 @@ local PROTOCOLS_OVERRIDE = {
}


local function get_exp_and_priority(route)
-- net.port => net.dst.port
local function transform_expression(route)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about naming this function "migrate_deprecated_variables"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will have more transform actions in the future, not only for migration.

Comment on lines +71 to +75
HTTP_SCHEMA = generate_schema(fields.HTTP_FIELDS)
STREAM_SCHEMA = generate_schema(fields.STREAM_FIELDS)

-- used by running router
CACHED_SCHEMA = is_http and HTTP_SCHEMA or STREAM_SCHEMA
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems one of those is not used. Is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, HTTP_SCHEMA and STREAM_SCHEMA will be used by validation.

@ADD-SP ADD-SP merged commit 25aa629 into release/3.5.x Mar 7, 2024
24 checks passed
@ADD-SP ADD-SP deleted the cherry/http_segments_matching_35 branch March 7, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants