Skip to content

Commit 4c12fd3

Browse files
authored
Merge branch 'main' into kcl/konnect-eventgateway
2 parents 4b2c4b0 + a54545a commit 4c12fd3

File tree

13 files changed

+26
-23
lines changed

13 files changed

+26
-23
lines changed

.github/workflows/__kongintegration_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
env:
9090
GOTESTSUM_JUNITFILE: ${{ env.GOTESTSUM_JUNITFILE }}
9191
KONG_CUSTOM_DOMAIN: konghq.tech
92-
TEST_KONG_KONNECT_ACCESS_TOKEN: ${{ secrets.KONG_TEST_KONNECT_ACCESS_TOKEN }}
92+
KONG_TEST_KONNECT_ACCESS_TOKEN: ${{ secrets.KONG_TEST_KONNECT_ACCESS_TOKEN }}
9393
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
9494
TEST_KONG_ENTERPRISE: ${{ matrix.enterprise }}
9595

.github/workflows/release-bot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
106106
with:
107107
egress-policy: audit
108-
- uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0
108+
- uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
109109
with:
110110
body: |
111111
#### Download Kong Operator ${{ needs.semver.outputs.version }}:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
now include a hash of rule's other field to avoid naming collisions with other
131131
rules that also have no BackendRefs.
132132
[#3576](https://github.com/Kong/kong-operator/pull/3576)
133+
- Do not try to list `Gateway`s for namespaces that are not being watched by controller
134+
[#3625](https://github.com/Kong/kong-operator/pull/3625)
133135

134136
## [v2.1.2]
135137

controller/gateway/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type Reconciler struct {
7373
KonnectEnabled bool
7474
AnonymousReportsEnabled bool
7575
LoggingMode logging.Mode
76+
WatchNamespaces []string
7677
}
7778

7879
// provisionDataPlaneFailRequeueAfter is the time duration after which we retry provisioning

controller/gateway/controller_watch.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"reflect"
8+
"slices"
89

910
"github.com/samber/lo"
1011
corev1 "k8s.io/api/core/v1"
@@ -350,6 +351,11 @@ func (r *Reconciler) listManagedGatewaysInNamespace(ctx context.Context, obj cli
350351
)
351352
return nil
352353
}
354+
if len(r.WatchNamespaces) > 0 && !slices.Contains(r.WatchNamespaces, ns.Name) {
355+
log.Trace(logger, "namespace is not configured to be watched by controller, skipping", "namespace", ns.Name)
356+
return nil
357+
}
358+
353359
gateways := &gatewayv1.GatewayList{}
354360
if err := r.List(ctx, gateways, &client.ListOptions{
355361
Namespace: ns.Name,

ingress-controller/test/helpers/konnect/access.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
package konnect
22

33
import (
4-
"os"
5-
"testing"
6-
74
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
85

96
"github.com/kong/kong-operator/v2/ingress-controller/test"
107
)
118

12-
// SkipIfMissingRequiredKonnectEnvVariables skips the test if the required Konnect environment variables are missing.
13-
func SkipIfMissingRequiredKonnectEnvVariables(t *testing.T) {
14-
if accessToken() == "" {
15-
t.Skip("missing TEST_KONG_KONNECT_ACCESS_TOKEN")
16-
}
17-
}
18-
19-
// accessToken returns the access token to be used for Konnect API requests.
20-
func accessToken() string {
21-
return os.Getenv("TEST_KONG_KONNECT_ACCESS_TOKEN")
22-
}
23-
249
// konnectControlPlaneAdminAPIBaseURL returns the base URL for Konnect Control Plane Admin API.
2510
// NOTE: This is a temporary solution until we migrate all the Konnect API calls to the new SDK.
2611
func konnectControlPlaneAdminAPIBaseURL() string {

ingress-controller/test/helpers/konnect/certificates.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/stretchr/testify/require"
1717

1818
"github.com/kong/kong-operator/v2/ingress-controller/internal/konnect/sdk"
19+
"github.com/kong/kong-operator/v2/test"
1920
"github.com/kong/kong-operator/v2/test/helpers/certificate"
2021
)
2122

@@ -37,7 +38,7 @@ func CreateClientCertificate(ctx context.Context, t *testing.T, cpID string, tok
3738

3839
var s *sdkkonnectgo.SDK
3940
if len(token) == 0 {
40-
s = sdk.New(accessToken(), serverURLOpt(), retryConfig)
41+
s = sdk.New(test.KonnectAccessToken(), serverURLOpt(), retryConfig)
4142
} else {
4243
s = sdk.New(token[0], serverURLOpt(), retryConfig)
4344
}

ingress-controller/test/helpers/konnect/control_plane.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
managercfg "github.com/kong/kong-operator/v2/ingress-controller/pkg/manager/config"
2121
"github.com/kong/kong-operator/v2/ingress-controller/test"
2222
"github.com/kong/kong-operator/v2/ingress-controller/test/testenv"
23+
testhelpers "github.com/kong/kong-operator/v2/test"
2324
"github.com/kong/kong-operator/v2/test/helpers/deploy"
2425
)
2526

@@ -32,7 +33,7 @@ func CreateTestControlPlane(ctx context.Context, t *testing.T, token ...string)
3233

3334
var s *sdkkonnectgo.SDK
3435
if len(token) == 0 {
35-
s = sdk.New(accessToken(), serverURLOpt())
36+
s = sdk.New(testhelpers.KonnectAccessToken(), serverURLOpt())
3637
} else {
3738
s = sdk.New(token[0], serverURLOpt())
3839
}

ingress-controller/test/helpers/konnect/personal_access_tokens.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/stretchr/testify/require"
1414

1515
"github.com/kong/kong-operator/v2/ingress-controller/internal/konnect/sdk"
16+
testhelpers "github.com/kong/kong-operator/v2/test"
1617
)
1718

1819
// CreateTestPersonalAccessToken creates a personal access token for the user
@@ -23,7 +24,7 @@ import (
2324
func CreateTestPersonalAccessToken(ctx context.Context, t *testing.T) string {
2425
t.Helper()
2526

26-
s := sdk.New(accessToken(), serverURLOpt())
27+
s := sdk.New(testhelpers.KonnectAccessToken(), serverURLOpt())
2728

2829
me, err := s.Me.GetUsersMe(ctx)
2930
require.NoError(t, err)

ingress-controller/test/helpers/konnect/system_account_tokens.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import (
1313
"github.com/stretchr/testify/require"
1414

1515
"github.com/kong/kong-operator/v2/ingress-controller/internal/konnect/sdk"
16+
testhelpers "github.com/kong/kong-operator/v2/test"
1617
)
1718

1819
func CreateTestSystemAccountToken(ctx context.Context, t *testing.T, systemAccountID string) (string, string) {
1920
t.Helper()
2021

21-
s := sdk.New(accessToken(), serverURLOpt())
22+
s := sdk.New(testhelpers.KonnectAccessToken(), serverURLOpt())
2223

2324
var (
2425
systemAccountToken string

0 commit comments

Comments
 (0)