-
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
refactor(clustering/compat): using array to store compatible checker functions #10152
Conversation
d6d7909
to
1025f94
Compare
kong/clustering/compat/init.lua
Outdated
has_update = true | ||
end | ||
end | ||
for ver, fn in pairs(compatible_checkers) do |
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 not sure that pairs()
is sufficient for this. There is an expectation that the compatibility change functions are executed in descending order (3.2.0.0
, then 3.1.0.0
, then 3.0.0.0
, etc).
Curious, have you taken a look at the compat code in koko? It's not without its quirks, but I think this would be a good pattern for us to follow--pretty big task to implement though.
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.
Thanks for your opinion. I have changed the hash table to an array.
Do you think it is OK?
Need update to #10192 |
For the compact problem, I have another piece of advice. we have all of the kong schemas, and we know all of the kong version schemas, Could this compatibility logic be solved in a similar way to how we use code generation in bindgen? we use more reliable code(iterating all kong schema) to generate the Version compatibility code. |
cf83987
to
79e6f1e
Compare
ea0a4d5
to
56e3cee
Compare
56e3cee
to
a96a9a3
Compare
Need update to #10400 |
aee3033
to
082e6d8
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.
The instance_name part looks OK to me. And also has a corresponding test to cover that.
1582258
to
52a7a4a
Compare
It is a good idea, perhaps we can do it in another PR in the future. |
It is a very valuable suggestion, thank you @vm-001. But Applying these changes may need more time and discussion, I think we could improve it in another PR later. |
Agree with @attenuation . And I think the current logic for compatibility is so complex, and we have to write the spec very carefully for ensuring the compatibility won't be broken when schemas are changed. It should have been a chance to simplify it, cause I think it's the DP's responsibility to ensure it can work even if it receives a unexpected config, most of the time it just receives some unknown fields or so. DP should have been capable to protect itself, at the same time, from the perspective of the users. DP should have been capable to ensure there is no unexpected behavior for the users as well. |
only log warn once style fix change to array style clean checkers.lua lint fix
52a7a4a
to
083b4a8
Compare
Updated to #10501. |
I think it is CPs responsibility to send right config in a first place. The DPs should just put everything CP sends in LMDB. The DPs also already have ability to remove unknown fields on read. It would also be great if CP streams config in such a way that it could be easily be imported in LMDB, and not through all the unnecessary parsing, flattening, validation - so what you describe is what DPs already do, just that we need to remove the validation/flattening part when receiving config so that it does not error on it, of course this needs then to be backported to all supported lower versions. The current way we do this is backwards. We try to remove unknown fields on CP side while we still allow configuring them. You cannot ever solve this issue with it: CP 1.0: DP 1.0: CP upgraded to 1.1: DP 1.0: DP 1.1: On DBless it is worth to error on invalid config. just not on hybrid as there we should not have invalid configs in a first place, which means CP should use lowest (supported) common denominator when selecting schema version (which is set by the oldest supported connected DP, and when CP starts to support newer schema it should forbid older DPs connecting). |
@chronolaw Please open the corresponding EE cherry pick PR. |
Sure, but this PR need #10400 and #10501 to be cherry-picked first. |
@chronolaw Please help out reviewing the cherrypicks of those PRs and then work on cherry-picking this one. |
@chronolaw @hbagdi , as not yet manually cherry-picked. This will be cherry-picked by CE2EE merge PR: https://github.com/Kong/kong-ee/pull/4985. |
Summary
Move compatible config-checking logic into a hash table, making code more readable.
Need special cherry-pick action to EE after #10400 and #10501 be cherry-picked.
Checklist