From 4b8ed8c147bc0fa0aa30d011af1f22e57bb491b7 Mon Sep 17 00:00:00 2001 From: Matias Charriere Date: Thu, 27 Jun 2024 11:36:02 +0200 Subject: [PATCH 1/2] Change label for vintage/capi detection Signed-off-by: Matias Charriere --- CHANGELOG.md | 4 ++++ controllers/cluster_controller.go | 2 +- controllers/utility.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e76cac2..fcf70eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Change the label used to detect whether the Cluster is Vintage or CAPI based. + ## [0.10.0] - 2024-04-30 ### Added diff --git a/controllers/cluster_controller.go b/controllers/cluster_controller.go index b7d4d38..f33ac6c 100644 --- a/controllers/cluster_controller.go +++ b/controllers/cluster_controller.go @@ -116,7 +116,7 @@ func (r *ClusterReconciler) reconcile(ctx context.Context, cluster *capi.Cluster if deletionTimeReached(cluster) { if !r.DryRun { // if it's a vintage cluster, we just try to remove the Cluster CR - if _, ok := cluster.Labels[vintageReleaseVersion]; ok { + if _, ok := cluster.Labels[clusterOperatorVersion]; ok { err := deleteVintageCluster(ctx, log, r.Client, cluster) if err != nil { return ctrl.Result{}, err diff --git a/controllers/utility.go b/controllers/utility.go index c246a6e..4da956f 100644 --- a/controllers/utility.go +++ b/controllers/utility.go @@ -32,7 +32,7 @@ const ( // fluxLabel is the label for checking if the cluster is created via git-ops fluxLabel = "kustomize.toolkit.fluxcd.io/name" - vintageReleaseVersion = "release.giantswarm.io/version" + clusterOperatorVersion = "cluster-operator.giantswarm.io/version" ) func requeue() reconcile.Result { From 65c740f8ffeb58e078eb8fd137355af35fa574c7 Mon Sep 17 00:00:00 2001 From: Matias Charriere Date: Thu, 27 Jun 2024 11:43:41 +0200 Subject: [PATCH 2/2] fix tests Signed-off-by: Matias Charriere --- controllers/cluster_controller_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/cluster_controller_test.go b/controllers/cluster_controller_test.go index 38504d7..68a562b 100644 --- a/controllers/cluster_controller_test.go +++ b/controllers/cluster_controller_test.go @@ -54,7 +54,7 @@ func TestClusterController(t *testing.T) { Time: time.Now().Add(-defaultTTL), }, Labels: map[string]string{ - "release.giantswarm.io/version": "18.2.1", + "cluster-operator.giantswarm.io/version": "5.1.1", }, Annotations: map[string]string{}, Finalizers: []string{ @@ -187,8 +187,8 @@ func TestClusterController(t *testing.T) { }, Annotations: map[string]string{}, Labels: map[string]string{ - keepUntil: "2020-12-08", - "release.giantswarm.io/version": "18.2.1", + keepUntil: "2020-12-08", + "cluster-operator.giantswarm.io/version": "5.1.1", }, Finalizers: []string{ "operatorkit.giantswarm.io/cluster-operator-cluster-controller", @@ -214,7 +214,7 @@ func TestClusterController(t *testing.T) { "kustomize.toolkit.fluxcd.io/name": "flux", }, Labels: map[string]string{ - "release.giantswarm.io/version": "18.2.1", + "cluster-operator.giantswarm.io/version": "5.1.1", }, Finalizers: []string{ "operatorkit.giantswarm.io/cluster-operator-cluster-controller", @@ -402,7 +402,7 @@ func TestClusterAppDeletion(t *testing.T) { Time: time.Now().Add(-defaultTTL), }, Labels: map[string]string{ - "release.giantswarm.io/version": "18.2.1", + "cluster-operator.giantswarm.io/version": "5.1.1", }, Annotations: map[string]string{ helmReleaseNameAnnotation: "test",