SouthwestAsiaFloat opened a new pull request, #7847:
URL: https://github.com/apache/shenyu/pull/7847
### Changes
Support upstream labels through the existing discovery `props` JSON:
- Validate label keys and values before Admin writes and imports.
- Preserve submitted properties during configuration synchronization.
- Parse labels separately from scalar metadata on gateway upstreams.
- Refresh cached labels and metadata while preserving health-check state and
request statistics.
Omitting `labels` or submitting an empty object clears existing labels.
Explicit `null` labels and non-string label values are rejected.
### Example
Upstream `props`:
```json
{
"warmup": 10,
"gray": false,
"healthCheckEnabled": true,
"labels": {
"release": "canary", ## just an example, not meaning that this pr is
related to realizing canary routing.
"region": "cn-east"
}
}
```
Admin validates labels → saves the complete `props` JSON → synchronizes it
to the gateway → gateway parses labels separately from scalar metadata →
updates the upstream cache.
Cache updates preserve health-check state and request statistics. Labels do
not change routing behavior in this PR.
### Architecture and data flow
```mermaid
flowchart TD
subgraph Admin
API["Existing APIs / discovery / config imports"]
Service["MODIFIED:
DiscoveryUpstreamServiceImpl<br/>ProxySelectorServiceImpl"]
Validator["NEW: DiscoveryUpstreamPropsValidator"]
DB[("EXISTING: discovery_upstream.props<br/>Complete JSON
properties")]
API --> Service
Service -. "validate before writes" .-> Validator
Service -->|"save after validation"| DB
end
Shared["NEW: UpstreamLabelsUtils<br/>Shared label validation"]
Validator -.-> Shared
Sync["EXISTING: configuration synchronization<br/>Carry props unchanged"]
DB --> Sync
subgraph Gateway
Props["MODIFIED: UpstreamProps<br/>Parse scalar metadata and labels
separately"]
Handler["MODIFIED: DivideUpstreamDataHandler<br/>Assign labels to
Upstream"]
Cache["MODIFIED: UpstreamCacheManager<br/>Refresh labels and
metadata by logical identity"]
Upstream["MODIFIED: cached Upstream<br/>Immutable labels
map<br/>Preserved health state and statistics"]
Props --> Handler --> Cache --> Upstream
end
Sync --> Props
Props -. "reuse label validation" .-> Shared
```
### Checklist
- [x] You have read the contribution guidelines.
- [x] You submit test cases that back your changes.
- [x] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`. The affected-module clean test build passed as
described above.
--
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]