wy471x opened a new pull request, #7288:
URL: https://github.com/apache/shenyu/pull/7288

   Fixes #6490
   
   Make sure that:
   
   - [X] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [X] You submit test cases (unit or integration tests) that back your 
changes.
   - [X] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   
   ## Summary
   
   `GrpcParser` looked up the endpoints of the backend service and dereferenced 
the result immediately, in `parseDefaultService()` and in `parseUpstream()`:
   
   ```java
   V1Endpoints v1Endpoints = 
endpointsLister.namespace(namespace).get(serviceName);
   List<V1EndpointSubset> subsets = v1Endpoints.getSubsets();
   ```
   
   When the service exists but its `Endpoints` object is not in the informer 
cache yet — during a rollout, a scale-up, or informer ordering — the lister 
returns `null` and the reconcile cycle fails with a `NullPointerException`, so 
the ingress is not configured at all. `DivideIngressParser` and 
`WebSocketParser` already guard against this.
   
   ### Changes:
   
   1. `GrpcParser.parseDefaultService()` (GrpcParser.java:156) — returns an 
empty upstream list when the endpoints of the default backend service are 
absent, so the global default backend is configured without upstreams and a 
later reconcile adds them once the endpoints exist.
   2. `GrpcParser.parseUpstream()` (GrpcParser.java:191) — same guard for the 
backend service of an ingress path, an empty selector handle is generated 
instead of failing the parse.
   
   Both guards mirror the existing behaviour and log messages of 
`DivideIngressParser` and `WebSocketParser`.
   
   ### Test Cases:
   
   `GrpcParserMissingEndpointsTest` (new), built on a service that has no 
endpoints in the lister:
   
   - `testParseDefaultBackendWithoutEndpoints` — parsing an ingress whose 
default backend service has no endpoints does not throw and produces a global 
default backend with an empty upstream handle.
   - `testParseRuleBackendWithoutEndpoints` — parsing an ingress whose path 
backend service has no endpoints does not throw and produces a route config 
with an empty upstream handle.
   - `testParseRuleBackendWithEndpoints` — the rule backend is still translated 
into an upstream when the endpoints are present, guarding the new early returns.
   
   Both missing-endpoints tests fail with the original code: 
`NullPointerException: Cannot invoke 
"io.kubernetes.client.openapi.models.V1Endpoints.getSubsets()" because 
"v1Endpoints" is null`.
   
   Note: the identical guard for `DubboIngressParser` is tracked separately by 
#6484 / #6859 (partially covered by #7042), it is intentionally not part of 
this change.
   
   ## Verification
   
   - `mvn -pl shenyu-kubernetes-controller test` — 23 tests, 0 failures.
   - `mvn -pl shenyu-kubernetes-controller validate` — checkstyle passed.
   
   close #6490


-- 
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]

Reply via email to