From eaa360ceaa5ac4375cec8324ba619290cf347bc2 Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Fri, 20 Dec 2024 17:14:24 +0100 Subject: [PATCH] fix: konnectExtension with bg enabled (#910) * fix: konnectExtension with bg enabled This commit fixes a bug related to KonnectExtensions for DataPlane configured with BlueGreen. In such configurations, the preview deployment was not customized with the Konnect-related field. Both the live and preview deployments are now properly customized with konnect fields. Signed-off-by: Mattia Lavacca * chore: add CHANGELOG entry Signed-off-by: Mattia Lavacca --------- Signed-off-by: Mattia Lavacca --- CHANGELOG.md | 6 ++++++ controller/dataplane/bluegreen_controller.go | 16 ++++++++++++++++ modules/manager/controller_setup.go | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61aedec3..5eff9438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,12 @@ anymore - default is set to `konghq.com`. [#947](https://github.com/Kong/gateway-operator/pull/947) +### Fixes + +- Fix `DataPlane`s with `KonnectExtension` and `BlueGreen` settings. Both the Live + and preview deployments are now customized with Konnect-related settings. + [#910](https://github.com/Kong/gateway-operator/pull/910) + ## [v1.4.1] > Release date: 2024-11-28 diff --git a/controller/dataplane/bluegreen_controller.go b/controller/dataplane/bluegreen_controller.go index 8c654c99..6091dabc 100644 --- a/controller/dataplane/bluegreen_controller.go +++ b/controller/dataplane/bluegreen_controller.go @@ -63,6 +63,8 @@ type BlueGreenReconciler struct { ContextInjector ctxinjector.CtxInjector DefaultImage string + + KonnectEnabled bool } // SetupWithManager sets up the controller with the Manager. @@ -135,6 +137,20 @@ func (r *BlueGreenReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // DataPlane is ready and we can proceed with deploying preview resources. + // customize the dataplane with the extensions field + log.Trace(logger, "applying extensions") + patched, requeue, err := applyExtensions(ctx, r.Client, logger, &dataplane, r.KonnectEnabled) + if err != nil { + if !requeue { + log.Debug(logger, "failed to apply extensions", "err", err) + return ctrl.Result{}, nil + } + return ctrl.Result{}, err + } + if patched { + return ctrl.Result{}, nil + } + // Ensure "preview" Admin API service. res, dataplaneAdminService, err := r.ensurePreviewAdminAPIService(ctx, logger, &dataplane) if err != nil { diff --git a/modules/manager/controller_setup.go b/modules/manager/controller_setup.go index ad381309..10b33ed2 100644 --- a/modules/manager/controller_setup.go +++ b/modules/manager/controller_setup.go @@ -450,7 +450,8 @@ func SetupControllers(mgr manager.Manager, c *Config) (map[string]ControllerDef, BeforeDeployment: dataplane.CreateCallbackManager(), AfterDeployment: dataplane.CreateCallbackManager(), }, - DefaultImage: consts.DefaultDataPlaneImage, + DefaultImage: consts.DefaultDataPlaneImage, + KonnectEnabled: c.KonnectControllersEnabled, }, }, DataPlaneOwnedServiceFinalizerControllerName: {