Kong / deck

decK: Configuration management and drift detection for Kong
https://docs.konghq.com/deck/overview
Apache License 2.0
434 stars 129 forks source link

Consumer groups with tags and distributed configuration #840

Open gregoirechauvet opened 1 year ago

gregoirechauvet commented 1 year ago

Tags have been added to consumer groups in https://github.com/Kong/deck/pull/823 But despite this addition, it seems a distributed configuration doesn't work with consumer groups. I've tested it on deck v1.17.2 which is the version that includes the consumer group tags addition.

Reproduction

Create consumer groups from a configuration with select_tags: global.

# In config/consumer-groups.yml
_format_version: "3.0"
_konnect:
  runtime_group_name: default

_info:
  select_tags:
  - global

consumer_groups:
- name: gold
  plugins:
  - name: rate-limiting-advanced
    config:
      limit:
      - 200
      window_size:
      - 60
      window_type: sliding
deck sync -s config/

And then try to create a service from another location with another select tag:

# In my-service/services.yml
_format_version: "3.0"
_konnect:
  runtime_group_name: default

_info:
  select_tags:
  - client-api

services:
- name: client-api
  host: example.domain
  port: 80
  path: /api
  protocol: http
deck diff -s my-service/

It results in the following output. The consumer groups should be deleted from decK's perspective. Whereas other entities such as services and plugins are ignored properly.

creating service client-api
deleting consumer-group gold
Summary:
  Created: 1
  Updated: 0
  Deleted: 1

Investigation

I've investigated decK hoping I could contribute to it by fixing this behavior. But my conclusion is that the error comes from the /v1/consumer-groups endpoint that doesn't filter on tags: https://github.com/Kong/deck/blob/629712b81ebebf9df4b2b60127cc62e9a4b8cb52/konnect/consumer_group.go#L432

The full endpoint decK is using in my case is:

https://eu.api.konghq.com/konnect-api/api/runtime_groups/[RUNTIME_GROUP_ID]/v1/consumer-groups

I've tried it on the CLI, and it ignores the tags when sent as parameters (?tags=client-api). As opposed to endpoints such as /services which filter correctly on tags. I could not find any documentation about /v1/consumer-groups, only about /consumer_groups. Any reason not to use the second one instead? Should the first one be documented?

aboudreault commented 1 year ago

@gregoirechauvet Thank you very much for this ticket, and your investigation! I have been able to reproduce the issue with your steps. There are indeed 2 different issues:

  1. the tags filtering doesn't work as expected with the konnect endpoint
  2. the tags filter is not added properly by deck (like the other endpoints).

we are going to provide fixes as soon as possible and keep you on touch.

About the different endpoints for consumer groups, this is expected. There are some differences in the implementation between Konnect (saas) vs Kong. Usually, konnect users don't deal with the endpoint directly so that's why it is not documented.

GGabriele commented 1 year ago

Hi @gregoirechauvet , would you mind testing it again with decK v1.25.0? This version should have fixed this issue.