Skip to content

Commit e37c1cd

Browse files
randmonkeypmalek
andauthored
fix(konnect): Use correct label value of secret to store license (#7648)
* fix label value of secret to store license * Update internal/labels/labels.go Co-authored-by: Patryk Małek <[email protected]> * check secret for stored license --------- Co-authored-by: Patryk Małek <[email protected]>
1 parent a278f8c commit e37c1cd

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ Adding a new version? You'll need three changes:
111111
- [0.0.5](#005)
112112
- [0.0.4 and prior](#004-and-prior)
113113

114+
## Unreleased
115+
116+
### Fixed
117+
118+
- Fix the issue that invalid label value causing KIC failed to store the license
119+
from Konnect into `Secret`.
120+
[#7648](https://github.com/Kong/kubernetes-ingress-controller/pull/7648)
121+
114122
## [3.5.0]
115123

116124
> Release date: 2025-07-02

internal/konnect/license/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ func (c *Client) Get(ctx context.Context) (mo.Option[license.KonnectLicense], er
9494

9595
if c.enableLicenseStorage && l.IsPresent() {
9696
err = c.licenseStore.Store(ctx, l.MustGet())
97-
c.logger.Error(err, "failed to store retrieved license to local storage")
97+
if err != nil {
98+
c.logger.Error(err, "failed to store retrieved license to local storage")
99+
}
98100
}
99101

100102
return l, nil

internal/labels/labels.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const (
2424

2525
// ManagedByLabel is the label key to mark that the object is managed by a specific controller.
2626
ManagedByLabel = LabelPrefix + ManagedByKey
27-
// ManagedByLabelValueIngressController is the label value that marks the object is managed byu KIC.
28-
ManagedByLabelValueIngressController = LabelPrefix + "/ingress-controller"
27+
// ManagedByLabelValueIngressController is the label value that marks the object is managed by KIC.
28+
ManagedByLabelValueIngressController = "kong-ingress-controller"
2929
)
3030

3131
// ValidateType indicates the type of validation applied to a Secret.

test/e2e/konnect_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212
"time"
1313

14+
"github.com/blang/semver/v4"
1415
environment "github.com/kong/kubernetes-testing-framework/pkg/environments"
1516
"github.com/samber/lo"
1617
"github.com/stretchr/testify/assert"
@@ -122,6 +123,15 @@ func TestKonnectLicenseActivation(t *testing.T) {
122123
}
123124
return license.License.Expiration != ""
124125
}, adminAPIWait, time.Second)
126+
127+
skipTestIfControllerVersionBelow(t, semver.MustParse("3.5.1"))
128+
t.Log("checking if the license is stored in the local secret")
129+
secret, err := env.Cluster().Client().CoreV1().Secrets(namespace).Get(
130+
ctx, "konnect-license-"+rgID, metav1.GetOptions{})
131+
require.NoError(t, err)
132+
require.NotNil(t, secret.Data, "secret to store Konnect license should not be empty")
133+
require.NotEmpty(t, secret.Data["id"], "stored license should have a non-empty ID")
134+
125135
t.Log("done")
126136
}
127137

test/e2e/utils_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ func extractVersionFromImage(imageName string) (semver.Version, error) {
189189
// below the minVersion.
190190
// if the override KIC image is not set, it assumes that the latest image is used, so it never skips
191191
// the test if override image is not given.
192-
//
193-
//lint:ignore U1000 retained for future use
194192
func skipTestIfControllerVersionBelow(t *testing.T, minVersion semver.Version) {
195193
if testenv.ControllerImageTag() == "" {
196194
return

0 commit comments

Comments
 (0)