Skip to content

[BUG] Kubernetes gRPC/Sofa context-path parsing reads annotations from the wrong resource #6492

Description

@Aias00

Current Behavior

For Prefix-type gRPC/Sofa ingresses, context-path parsing reads context-path annotations from the ingress metadata, while the repository examples put those annotations on the Service metadata.

IngressParser.contextPathParse() creates ContextPathParser for Prefix paths using the ingress object. ContextPathParser.createContextMappingRuleHandle() then reads:

ruleHandle.setContextPath(annotations.get(IngressConstants.PLUGIN_CONTEXT_PATH_PATH));

The gRPC and Sofa Kubernetes examples place shenyu.apache.org/plugin-context-path-path on the Service, next to the RPC metadata annotations, not on the Ingress. With that shape, context-path parsing can generate a rule with contextPath == null and a path condition like null/**.

Expected Behavior

Context-path parsing should read the annotation from the same resource where the RPC parser expects the service metadata, or the examples and parser contract should be aligned so valid examples do not generate invalid context-path rules.

Impact

The documented/example gRPC and Sofa ingress setup can produce broken context-path rules for Prefix paths.

Code Location

  • shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/IngressParser.java
  • shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/ContextPathParser.java
  • shenyu-examples/shenyu-examples-grpc/k8s/ingress.yml
  • shenyu-examples/shenyu-examples-sofa/shenyu-examples-sofa-service/k8s/ingress.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions