cvas22 opened a new pull request, #14231: URL: https://github.com/apache/apisix/pull/14231
### Description This picks up the consul part of #12448, which went stale. When the instances of one consul service are told apart by their `Meta` (stable vs canary, lanes and so on), there's no way today to point an upstream at just a subset of them. I added a `preserve_metadata` option to the consul discovery config (off by default, so nothing changes for existing setups) and a `discovery_args.metadata` map on the upstream. With both set, the upstream only gets the instances whose metadata has all the given key/value pairs. The metadata itself is dropped from the nodes handed to the upstream, because the cached node list is decoded again every second and fresh metadata tables would otherwise look like a node change on each refresh. Filtered lists are cached per worker and rebuilt only when the underlying cached list changes. If an upstream sets `discovery_args.metadata` while `preserve_metadata` is off, the admin API rejects it, and on a data plane it's ignored with a single warning instead of dropping the upstream. I kept it to `Meta` and left tags out to keep the change small. Tags could follow the same path later if people want it. There's no zh consul page yet, so the docs change is only in docs/en. I couldn't run Test::Nginx locally, so I'm relying on CI for the new t/discovery/consul-metadata.t. #### Which issue(s) this PR fixes: Fixes #13184 ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
