Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service field under a plugin should be ignored for nested routes #1353

Open
healthy-pod opened this issue Aug 3, 2024 · 2 comments
Open

Comments

@healthy-pod
Copy link

If the value of service.routes[*].plugins[*].service is set to the same service in which the route is nested, applying the configuration returns an entity already exists error.

For example, consider the following configuration:

---
_format_version: "3.0"
services:
- name: koko-private
  host: koko-cp-ws.koko.svc.cluster.local
  port: 3200
  protocol: http
  routes:
  - name: koko-private-cp
    hosts:
    - 'us.kgateway.svc.konghq.${{ env "DECK_DOMAIN_TLD" }}'
    - 'eu.kgateway.svc.konghq.${{ env "DECK_DOMAIN_TLD" }}'
    snis:
    - 'us.kgateway.svc.konghq.${{ env "DECK_DOMAIN_TLD" }}'
    - 'eu.kgateway.svc.konghq.${{ env "DECK_DOMAIN_TLD" }}'
    paths:
    - ~/cp/(.*)/v1/outlet
    strip_path: false
    plugins:
    - name: request-transformer
      service: koko-private
      config:
        add:
          querystring:
          - cluster.prefix:$(uri_captures[1])
        replace:
          uri: "/v1/outlet"

Applying it succeeds first time, but fails second time with an entity already exists error. Deleting the plugin manually from the service then re-applying works, but still fails on the next apply with the same issue.

Options:

  1. Completely ignore service field in plugins under a route which is explicitly defined under a service
  2. Validate that the service field for the plugin matches the service name under which the route is nested, otherwise return a validation error
@mheap
Copy link
Member

mheap commented Aug 3, 2024

My expectation of behaviour would be:

  1. Error if a foreign key is set in a nested config (even if it matches). Fail fast.

Can you help us understand how you landed on this configuration?

@healthy-pod
Copy link
Author

Can you help us understand how you landed on this configuration?

[noob kong user here] while working on the config above I wanted to add a request-transformer plugin to a route nested within a service definition so I went to https://docs.konghq.com/hub/kong-inc/request-transformer/how-to/basic-example/ and copied the declarative example under Enable on a service which starts with:

- name: request-transformer
  service: SERVICE_NAME|ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants