refactor(clustering): an optimization for the compatibility of CP and DP #12778
+115
−77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Background:
Kong ensures the backward compatibility through the logic of
remove_fields
that CP with higher verion can removes fields which are not supported by DPs in lower version before sending the configuration to DPs.In detail, CP checks the version reporting by DP. If the version from DP is less than the version defined in
remove_fields
, the fields will be removed. So the logic is just a simple comparison.Issue:
This logic works well for most of the cases. However, after serval backports to various version series, the comparsion should become more complex as there would be several incontinous ranges where the fields should be removed due to multiple backports.
Solution:
In this PR, a lower bound is added to the comparison when necessary rather than only a upper bound previously.
The new logic is that the comparison should punch through the range of the minor version for the earliest version since the field is supported, otherwise, the comparsion should be limited with the range of minor version.
Example
Let say a new field is initially introduced since 3.7.7. At this monent, an entry defined in
removed_fields.lua
should be:And then it is backported into 3.5.5, 3.6.6. After that, the ranges where it's going to be removed or not turns into the followings:
At this monent, in terms of the new logic, the
removed_fields.lua
should be:The comparsion should be
dp_version < 3005005000
for the first entry as it is the earliest version it is supported and it should punch through the minor version.The other two comparsions should be:
dp_version < 3006006000 and dp_version >= 3006000000
anddp_version < 3007007000 and dp_version >= 3007000000
respectively as it is not the earliest version it is supported and the comparison should be limited within the minor version.With the help of this change, the
removed_fields.lua
can be consistent across version series, and we can easily append a new entry correspondingly when there is a backport.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
Fix #[issue number]