Skip to content

Commit 9915eea

Browse files
authored
fix: dont fail when the platform namespace exists without the desired labels (#204)
* fix: dont fail when the platform namespace exists without the desired labels * feat: release v0.17.1
1 parent 35d4297 commit 9915eea

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.17.0-dev
1+
v0.17.1

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ require (
1414
github.com/onsi/ginkgo/v2 v2.27.2
1515
github.com/onsi/gomega v1.38.2
1616
github.com/openmcp-project/controller-utils v0.23.4
17-
github.com/openmcp-project/openmcp-operator/api v0.17.0
18-
github.com/openmcp-project/openmcp-operator/lib v0.17.0
17+
github.com/openmcp-project/openmcp-operator/api v0.17.1
18+
github.com/openmcp-project/openmcp-operator/lib v0.17.1
1919
github.com/spf13/cobra v1.10.1
2020
k8s.io/api v0.34.1
2121
k8s.io/apimachinery v0.34.1

internal/controllers/managedcontrolplane/controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77
"time"
88

9+
"github.com/openmcp-project/controller-utils/pkg/resources"
910
corev1 "k8s.io/api/core/v1"
1011
apierrors "k8s.io/apimachinery/pkg/api/errors"
1112
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -19,7 +20,6 @@ import (
1920
"sigs.k8s.io/controller-runtime/pkg/predicate"
2021
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2122

22-
"github.com/openmcp-project/controller-utils/pkg/clusteraccess"
2323
"github.com/openmcp-project/controller-utils/pkg/clusters"
2424
"github.com/openmcp-project/controller-utils/pkg/collections"
2525
"github.com/openmcp-project/controller-utils/pkg/collections/filters"
@@ -197,7 +197,15 @@ func (r *ManagedControlPlaneReconciler) handleCreateOrUpdate(ctx context.Context
197197
createCon(corev2alpha1.ConditionMeta, metav1.ConditionFalse, rr.ReconcileError.Reason(), rr.ReconcileError.Error())
198198
return rr
199199
}
200-
_, err = clusteraccess.EnsureNamespace(ctx, r.PlatformCluster.Client(), platformNamespace, pairs.MapToPairs(mcpLabels)...)
200+
// TODO: changed from clusteraccess.EnsureNamespace to a namespace mutator
201+
// because the MCP namespace might be created by another controller first (e.g. another service provider).
202+
// Failing in this case is not desired as the MCP reconciliation would be stuck.
203+
// Instead, we ensure that the labels are correct on the namespace.gi
204+
// In the future, we might want to refactor this further to have a more generic way of ensuring that the namespace exists with the correct labels,
205+
// regardless of which controller created it first.
206+
nsMutator := resources.NewNamespaceMutator(platformNamespace)
207+
nsMutator.MetadataMutator().WithLabels(mcpLabels)
208+
err = resources.CreateOrUpdateResource(ctx, r.PlatformCluster.Client(), nsMutator)
201209
if err != nil {
202210
rr.ReconcileError = errutils.WithReason(fmt.Errorf("error ensuring namespace '%s' on platform cluster: %w", platformNamespace, err), cconst.ReasonPlatformClusterInteractionProblem)
203211
createCon(corev2alpha1.ConditionMeta, metav1.ConditionFalse, rr.ReconcileError.Reason(), rr.ReconcileError.Error())

lib/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/onsi/ginkgo/v2 v2.27.2
99
github.com/onsi/gomega v1.38.2
1010
github.com/openmcp-project/controller-utils v0.23.4
11-
github.com/openmcp-project/openmcp-operator/api v0.17.0
11+
github.com/openmcp-project/openmcp-operator/api v0.17.1
1212
k8s.io/api v0.34.1
1313
k8s.io/apimachinery v0.34.1
1414
k8s.io/client-go v0.34.1

0 commit comments

Comments
 (0)