fix(targets): targets can't be removed from dns query queue #14298
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
For the deployment that multiple kong instances in traditional mode share the same database, when there are updates in targets via admin API happening on one of the instances, the related targets can not be removed from the DNS query queue via cluster events notification broadcasted by the initial instance.
This issue is that the payload in the cluster event broadcasted from other instances only contains the upstream ID attached to the target. However, the handler that is eventually supposed to consume the payload expects a target entity.
The issue is not caused by an incorrect payload in the cluster event, because the payload of a cluster event is transmitted via the database. Therefore, passing a smaller and simpler payload is a wise choice, whereas a complete target entity obviously has a more complex data structure.
In this PR, a list of all the related targets is retrieved from cached with the upstream id, and they are all removed from the queue. This is an acceptable approach as the related balancer entity will be reconstructed right away, meanwhile, all dns queries for the valid targets will be rescheduled as well.
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
FTI-6469