Skip to content

Commit a45678e

Browse files
authored
fix: added fix for creation errors in consumer_group_consumers while using mismatched lookup tags (#1576)
* tests: added partial-plugin tests for konnect * tests: reduced test duplication for konnect by setting CP in utils func * style: removed stray code * fix: added fix for creation errors in consumer_group_consumers while using lookup tags * tests: added integration tests * chore: added verbose flag in docker run command to check for container errors * fix: added -v flag to kong health command * ci: added continue_on_error condition for gateway-dev:latest image The setup stage is failing due to some reason
1 parent cbdc692 commit a45678e

File tree

9 files changed

+84
-9
lines changed

9 files changed

+84
-9
lines changed

.github/workflows/integration-enterprise.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
env:
5353
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
5454
run: make setup-kong-ee
55+
continue-on-error: ${{ matrix.kong_image == 'kong/kong-gateway-dev:latest' }}
5556
- name: Run integration tests
5657
env:
5758
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}

cmd/common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ func syncMain(ctx context.Context, filenames []string, dry bool, parallelism,
284284
}
285285

286286
if dumpConfig.LookUpSelectorTagsConsumerGroups != nil {
287-
consumerGroupsGlobal, err := dump.GetAllConsumerGroups(ctx, kongClient, dumpConfig.LookUpSelectorTagsConsumerGroups)
287+
consumerGroupsGlobal, err := dump.GetAllConsumerGroups(ctx, kongClient, dumpConfig.LookUpSelectorTagsConsumerGroups,
288+
dump.DefaultLookupTag)
288289
if err != nil {
289290
return fmt.Errorf("error retrieving global consumer groups via lookup selector tags: %w", err)
290291
}

cmd/gateway_validate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ func executeValidate(cmd *cobra.Command, _ []string) error {
5656
}
5757

5858
if lookUpSelectorTagsConsumerGroups != nil {
59-
consumerGroupsGlobal, err := dump.GetAllConsumerGroups(ctx, kongClient, lookUpSelectorTagsConsumerGroups)
59+
consumerGroupsGlobal, err := dump.GetAllConsumerGroups(ctx, kongClient, lookUpSelectorTagsConsumerGroups,
60+
dump.DefaultLookupTag)
6061
if err != nil {
6162
return fmt.Errorf("error retrieving global consumer groups via lookup selector tags: %w", err)
6263
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/fatih/color v1.18.0
1414
github.com/google/go-cmp v0.7.0
1515
github.com/kong/go-apiops v0.1.41
16-
github.com/kong/go-database-reconciler v1.21.0
16+
github.com/kong/go-database-reconciler v1.22.0
1717
github.com/kong/go-kong v0.64.1
1818
github.com/mitchellh/go-homedir v1.1.0
1919
github.com/spf13/cobra v1.8.1
@@ -58,7 +58,7 @@ require (
5858
github.com/google/uuid v1.6.0 // indirect
5959
github.com/gorilla/websocket v1.5.1 // indirect
6060
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
61-
github.com/hashicorp/go-memdb v1.3.4 // indirect
61+
github.com/hashicorp/go-memdb v1.3.5 // indirect
6262
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
6363
github.com/hashicorp/go-uuid v1.0.3 // indirect
6464
github.com/hexops/gotextdiff v1.0.3 // indirect

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,10 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
209209
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
210210
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
211211
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
212-
github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
213212
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
214213
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
215-
github.com/hashicorp/go-memdb v1.3.4 h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c=
216-
github.com/hashicorp/go-memdb v1.3.4/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg=
214+
github.com/hashicorp/go-memdb v1.3.5 h1:b3taDMxCBCBVgyRrS1AZVHO14ubMYZB++QpNhBg+Nyo=
215+
github.com/hashicorp/go-memdb v1.3.5/go.mod h1:8IVKKBkVe+fxFgdFOYxzQQNjz+sWCyHCdIC/+5+Vy1Y=
217216
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
218217
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
219218
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
@@ -247,8 +246,8 @@ github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/q
247246
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
248247
github.com/kong/go-apiops v0.1.41 h1:1KXbQqyhO2E4nEnXJNqUDmHZU/LQ1U7Zoi+MAlcM2P0=
249248
github.com/kong/go-apiops v0.1.41/go.mod h1:sATq9Tz+ivzHKZU+tDXkRtEZnf64xroU3lgv3yXqP4I=
250-
github.com/kong/go-database-reconciler v1.21.0 h1:KoO63asW0uk/si+JvIpa/GHoov5vHwx4i7d+Eazc2hY=
251-
github.com/kong/go-database-reconciler v1.21.0/go.mod h1:AmYOR/Og7CHT8bB9zpbQCINpTT+C+WVNDjqfVxQT5V0=
249+
github.com/kong/go-database-reconciler v1.22.0 h1:xkcGFqjk1QattePNXHI2PYtQ4qh6Ibhkj+8aMBPQLZs=
250+
github.com/kong/go-database-reconciler v1.22.0/go.mod h1:emf04E6FSd5y9OKCMB+kNQ0NCTauSaEeCUNRCUgymSY=
252251
github.com/kong/go-kong v0.64.1 h1:HQssErFchbyYoDVQL7kR8x2naaY9mFgmDu/dXF0NZSo=
253252
github.com/kong/go-kong v0.64.1/go.mod h1:sqdysTKrXIJ6mpxHwTwjgZhLW7jR1/puczTXHLUwJaE=
254253
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=

tests/integration/sync_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7875,3 +7875,45 @@ func Test_Sync_Partials(t *testing.T) {
78757875
require.NoError(t, err)
78767876
})
78777877
}
7878+
7879+
func Test_Sync_Consumers_Default_Lookup_Tag(t *testing.T) {
7880+
runWhenEnterpriseOrKonnect(t, ">=2.8.0")
7881+
7882+
ctx := context.Background()
7883+
7884+
t.Run("no errors occur in case of subsequent syncs with distributed config and defaultLookupTags for consumer-group",
7885+
func(t *testing.T) {
7886+
// sync consumer-group file first
7887+
err := sync(ctx, "testdata/sync/015-consumer-groups/kong-cg.yaml")
7888+
t.Cleanup(func() {
7889+
reset(t)
7890+
})
7891+
require.NoError(t, err)
7892+
7893+
// sync consumers file
7894+
err = sync(ctx, "testdata/sync/015-consumer-groups/kong-consumers.yaml")
7895+
require.NoError(t, err)
7896+
7897+
// sync again
7898+
err = sync(ctx, "testdata/sync/015-consumer-groups/kong-consumers.yaml")
7899+
require.NoError(t, err)
7900+
})
7901+
7902+
t.Run("no errors occur in case of with distributed config when consumer is not tagged but consumer-group is",
7903+
func(t *testing.T) {
7904+
// sync consumer-group file first
7905+
err := sync(ctx, "testdata/sync/015-consumer-groups/kong-cg.yaml")
7906+
t.Cleanup(func() {
7907+
reset(t)
7908+
})
7909+
require.NoError(t, err)
7910+
7911+
// sync consumers file
7912+
err = sync(ctx, "testdata/sync/015-consumer-groups/kong-consumers-no-tag.yaml")
7913+
require.NoError(t, err)
7914+
7915+
// sync again
7916+
err = sync(ctx, "testdata/sync/015-consumer-groups/kong-consumers-no-tag.yaml")
7917+
require.NoError(t, err)
7918+
})
7919+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
_format_version: "3.0"
2+
consumer_groups:
3+
- name: foo-group
4+
tags:
5+
- group-tag
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
_format_version: "3.0"
2+
_info:
3+
defaults: {}
4+
default_lookup_tags:
5+
consumer_groups:
6+
- group-tag
7+
8+
consumers:
9+
- username: user-1
10+
groups:
11+
- name: foo-group
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
_format_version: "3.0"
2+
_info:
3+
defaults: {}
4+
select_tags:
5+
- user-tag
6+
default_lookup_tags:
7+
consumer_groups:
8+
- group-tag
9+
10+
consumers:
11+
- username: user-1
12+
groups:
13+
- name: foo-group
14+
tags:
15+
- user-tag

0 commit comments

Comments
 (0)