Aias00 opened a new issue, #6486:
URL: https://github.com/apache/shenyu/issues/6486
### Current Behavior
The Kubernetes RPC ingress parsers assume ingress labels and
label-referenced services are always present.
For Dubbo, gRPC, and Sofa route parsing, the code iterates `labels.keySet()`
and then immediately dereferences the service returned by
`serviceLister.namespace(namespace).get(labels.get(label))`:
```java
for (String label : labels.keySet()) {
Map<String, String> metadataAnnotations =
serviceLister.namespace(namespace)
.get(labels.get(label))
.getMetadata()
.getAnnotations();
...
}
```
If an ingress has rules but no labels, `labels` can be `null`. If a label
points to a service name that is not currently present in the local cache,
`serviceLister...get(...)` can return `null`. Both cases can throw
`NullPointerException` during reconciliation.
### Expected Behavior
The parsers should handle missing labels or missing referenced services
gracefully, for example by skipping that metadata/rule entry and allowing a
later reconcile after the service cache is populated.
### Steps to Reproduce
1. Create a Dubbo, gRPC, or Sofa ingress with `spec.rules` but without
metadata labels expected by the parser, or with a label value that references a
service not present in the controller cache.
2. Let the Shenyu Kubernetes controller reconcile it.
3. The parser can throw while iterating labels or reading service metadata
annotations.
### Code Location
-
`shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java`
-
`shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/GrpcParser.java`
-
`shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/SofaParser.java`
--
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]