-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(*): reject config if both deprecated and new field defined and their values mismatch #13565
fix(*): reject config if both deprecated and new field defined and their values mismatch #13565
Conversation
27cab5b
to
493588c
Compare
9621432
to
c24de51
Compare
I jumped the gun a little bit - let me add one more test 👀 |
c24de51
to
935ca82
Compare
935ca82
to
ea61bad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just asking.
translate_backwards = {'server_name'}, | ||
deprecation = { | ||
replaced_with = { { path = { 'server_name' } } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have translate_backwards
and now replaced_with
. what is the difference here and what is this path = ...
, there is no path =
with translate_backwards
. Can we use single thing for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan is to use only one of them - I want to get rid of translate_backwards
- however it would require quite a lot code removal so I wanted to get it in another PR. It's going to be a refactor PR so it's not going to block the release.
This addition - although it's a little bit of code duplication I think it's just safer / quicker path. I'll prepare cleanup PRs once this one is merged - I promise 😄
As a bonus I think we can even automate the message - I'm planning to still allow custom message but the way right now it's defined is rather repetitive and it looks like we have all the knowledge we need to generate those deprecation warnings automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus... the more I work with it the more I hate the name translate_backwards
- it's just confusing. replaced_with
inside deprecation
right now makes more sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan is to use only one of them
If both translate_backwards
and replaced_with
can fix the bug, we'd better stick with the translate_backwards
and avoid introducing an extra metaschema in this PR.
The refactor and introduction of replaced_with
can be made in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we cannot use only one of the since translate_backwards
is a single just a table path and we need to have an array of table paths. The reason is that one field can be replaced by a few fields ex: redis.timeout
and redis.connect_timeout
/ redis.send_timeout
/ redis.read_timeout
.
We need to have a way to check against all 3 of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a test case just for that. Maybe it explains it a little bit better: https://github.com/Kong/kong/pull/13565/files#diff-be157ebd3368ec7ae7c30ab60332aebbd18f627ec4fa680156e6d6cd1706f668R4233
I'm changing this back to draft since we've found some issues with this approach and gateway compatibility between the upcoming |
537cbab
to
a3ea812
Compare
…eir values mismatch This commit adds a validation to deprecated fields that checks if in case both new field and old field were defined - their values must match. Note that if one of the fields is null then the validation passes even if the other is not null. KAG-5262
a3ea812
to
eabcd44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1/n
… and their values mismatch PR fixes
2360ef6
to
e69e9fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with the current version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with a small possible perf optimization when an error is detected
… and their values mismatch PR fixes 2
…eir values mismatch (#13565) * fix(*): reject config if both deprecated and new field defined and their values mismatch This commit adds a validation to deprecated fields that checks if in case both new field and old field were defined - their values must match. Note that if one of the fields is null then the validation passes even if the other is not null. KAG-5262 * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch PR fixes * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch PR fixes 2 (cherry picked from commit d10408c)
Cherry-pick failed for Please cherry-pick the changes locally. git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-13565-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-13565-to-master-to-upstream
git checkout -b cherry-pick-13565-to-master-to-upstream
ancref=$(git merge-base 83de84393fbd7445cb68d72dea36d24890b2fc3a 125c653914ce0eb4f242fdc02ac8eb3dc35cb5c3)
git cherry-pick -x $ancref..125c653914ce0eb4f242fdc02ac8eb3dc35cb5c3 |
Successfully created backport PR for |
…eir values mismatch (Kong#13565) * fix(*): reject config if both deprecated and new field defined and their values mismatch This commit adds a validation to deprecated fields that checks if in case both new field and old field were defined - their values must match. Note that if one of the fields is null then the validation passes even if the other is not null. KAG-5262 * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch PR fixes * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch PR fixes 2
…eir values mismatch (#10121) * fix(*): reject config if both deprecated and new field defined and their values mismatch (#13565) * fix(*): reject config if both deprecated and new field defined and their values mismatch This commit adds a validation to deprecated fields that checks if in case both new field and old field were defined - their values must match. Note that if one of the fields is null then the validation passes even if the other is not null. KAG-5262 * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch PR fixes * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch PR fixes 2 (cherry picked from commit d10408c) * fixup! fix(*): reject config if both deprecated and new field defined and their values mismatch add EE plugins to deprecation mismatch validation (replaced_with)
Summary
This PR adds a validation to deprecated fields that checks the case in which both new field and old field were defined; when that happens their values must match.
It introduces a new structure to deprecation definition by adding
replaced_with
information. This way field validation can verify if thereplaced_with
field has the same value as the old deprecated field. By default the comparison is done via translation through simple path but there might be instances where translation from old to new is more complicated and then the translation function should be provided intranslation
field.The plan is to remove
translate_backwards
field in the future in favor ofreplaced_with
.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
KAG-5262