gateway icon indicating copy to clipboard operation
gateway copied to clipboard

HTTPRouteConfig file has a limitation for number of items in the Match object

Open BLasan opened this issue 2 years ago • 1 comments

Description: When defining more than 8 paths for the match object in HTTPRouteConfig file, it returns the following error message.

The HTTPRoute "petstore" is invalid: spec.rules[0].matches: Too many: 11: must have at most 8 items

In line no 644 of gatewayapi-crds.yaml, maxItems attribute has the value 8 which is causing the issue. Is there a rationale behind that value 8? Or is it just an arbitrary number for the testing purposes which is completely fine with removing/changing?

[optional Relevant Links:] https://github.com/envoyproxy/gateway/releases/download/v0.2.0-rc1/gatewayapi-crds.yaml

BLasan avatar Sep 19 '22 11:09 BLasan

@BLasan this is a maximum set by the Gateway API spec and I'm unaware of why 8 was decided. If this restriction is an issue, can you provide additional context by creating a Gateway API issue and linking to this issue for tracking purposes?

xref: https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go#L170

cc: @youngnick

danehans avatar Sep 20 '22 18:09 danehans

8 was a relatively arbitrary number chosen to maximise the chance that the whole record won't exceed the default etcd size limit. We felt that if you were matching more than 8 separate criteria, you could come and talk to us about why.

The Gateway API CRDs should not be changed though, they are imported from the upstream project, and changing them will make your installation incompatible with the upstream APIs.

I'd be interested to see why you need to go past 8 matches in one rule. Remember you can also have multiple rules.

youngnick avatar Sep 30 '22 00:09 youngnick

Hi @youngnick , we have a sample petstore swagger file which consists of more than 8 paths which needs to be converted to a HTTPRoute config file. That httproute config should consists of all paths in the swagger definition irrespective of the gateway implementation. If this is not the best practice, could you please suggest the most effective way of doing this and exposing it as an API? Also, this doesn’t support the path parameters in a particular path. (eg: /pet/{petid} cannot be configured as it is since {petid} is not considered as a path parameter.). Following is the sample httproute config file created from swagger

apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: demo-petstore
  labels:
    version: 1.0.1
spec:
  parentRefs:
  - name: eg
  hostnames:
  - www.example.com
  rules:
  - matches:
    - path:
        type: Exact
        value: /api/v3/pet/{petId}/uploadImage
      method: POST
    - path:
        type: Exact
        value: /api/v3/pet
      method: POST
    - path:
        type: Exact
        value: /api/v3/pet
      method: PUT   
    - path:
        type: Exact
        value: /api/v3/pet/findByStatus
      method: GET
    - path:
        type: Exact
        value: /api/v3/pet/findByTags
      method: GET
    - path:
        type: Exact
        value: /api/v3/pet/{petId}
      method: GET
    - path:
        type: Exact
        value: /api/v3/pet/{petId}
      method: POST
    - path:
        type: Exact
        value: /api/v3/pet/{petId}
      method: DELETE
    - path:
        type: Exact
        value: /api/v3/store/order
      method: POST
    - path:
        type: Exact
        value: /api/v3/store/order/{orderId}
      method: GET
    - path:
        type: Exact
        value: /api/v3/store/order/{orderId}
      method: DELETE
    - path:
        type: Exact
        value: /api/v3/store/inventory
      method: GET
    - path:
        type: Exact
        value: /api/v3/user/createWithArray
      method: POST
    - path:
        type: Exact
        value: /api/v3/user/createWithList
      method: POST
    - path:
        type: Exact
        value: /api/v3/user/{username}
      method: PUT

BLasan avatar Oct 03 '22 11:10 BLasan

This issue is created to track it in gateway api project - https://github.com/kubernetes-sigs/gateway-api/issues/1485

Amila-Rukshan avatar Oct 28 '22 05:10 Amila-Rukshan

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 27 '22 08:11 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar Dec 04 '22 08:12 github-actions[bot]

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar Jan 04 '23 20:01 github-actions[bot]