From 32b1ecbaab60d053d4c6b63a0db60742d45caa8f Mon Sep 17 00:00:00 2001 From: Alka Kumari Date: Wed, 5 Nov 2025 19:57:25 +0530 Subject: [PATCH] downstream the support for custom labels for configmap and secret created by argo-rollout Signed-off-by: Alka Kumari --- cmd/main.go | 5 + go.mod | 2 +- go.sum | 4 +- .../1-121_validate_custom_labels_rollouts.go | 98 +++++++++++++++++++ 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 test/openshift/e2e/ginkgo/parallel/1-121_validate_custom_labels_rollouts.go diff --git a/cmd/main.go b/cmd/main.go index 3c6d25252..abeabdc4e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -246,11 +246,16 @@ func main() { setupLog.Info("Argo Rollouts manager running in cluster-scoped mode") } + resourceLabels := map[string]string{ + argocdcommon.ArgoCDTrackedByOperatorLabel: argocdcommon.ArgoCDAppName, + } + if err = (&rolloutManagerProvisioner.RolloutManagerReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), OpenShiftRoutePluginLocation: getArgoRolloutsOpenshiftRouteTrafficManagerPath(), NamespaceScopedArgoRolloutsController: isNamespaceScoped, + ResourceLabels: resourceLabels, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Argo Rollouts") os.Exit(1) diff --git a/go.mod b/go.mod index a927dbe8c..a8adf072b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/redhat-developer/gitops-operator go 1.24.6 require ( - github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251104202229-c016d0810449 + github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765 github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251104052658-38b9581ce39a github.com/argoproj/argo-cd/v3 v3.1.8 github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec diff --git a/go.sum b/go.sum index 25ab7ef08..893fbdb12 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21j github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= -github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251104202229-c016d0810449 h1:EAU1bnt7xADjcTwjAbov5l7TsCWKTDBV59U1dCXKsU8= -github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251104202229-c016d0810449/go.mod h1:WPyZkNHZjir/OTt8mrRwcUZKe1euHrHPJsRv1Wp/F/0= +github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765 h1:zVN+W/nQrRB/kB63YcvcCseuiE//sEzNw6Oa8rqiFOs= +github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765/go.mod h1:WPyZkNHZjir/OTt8mrRwcUZKe1euHrHPJsRv1Wp/F/0= github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251104052658-38b9581ce39a h1:MruEtChFnhTI8Owa1Boqo7BChWxnVRkyhN1/dsg/VgQ= github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251104052658-38b9581ce39a/go.mod h1:ABtgKWsvMlUp6Xys8BVi0CHKdT9ZoFP+rYCqRsY0wvg= github.com/argoproj/argo-cd/v3 v3.1.8 h1:NkLPiRI5qGkV+q1EN3O7/0Wb9O/MVl62vadKteZqMUw= diff --git a/test/openshift/e2e/ginkgo/parallel/1-121_validate_custom_labels_rollouts.go b/test/openshift/e2e/ginkgo/parallel/1-121_validate_custom_labels_rollouts.go new file mode 100644 index 000000000..259d640c8 --- /dev/null +++ b/test/openshift/e2e/ginkgo/parallel/1-121_validate_custom_labels_rollouts.go @@ -0,0 +1,98 @@ +/* +Copyright 2025. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package parallel + +import ( + "context" + + rolloutmanagerv1alpha1 "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" + k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" + fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ = Describe("GitOps Operator Parallel E2E Tests", func() { + + Context("1-121_validate_custom_labels_rollouts", func() { + + var ( + k8sClient client.Client + ctx context.Context + ) + + BeforeEach(func() { + fixture.EnsureParallelCleanSlate() + k8sClient, _ = fixtureUtils.GetE2ETestKubeClient() + ctx = context.Background() + }) + + It("ensures that custom labels set by the operator are added to Argo Rollouts resources", func() { + + By("creating namespace-scoped RolloutManager instance") + rolloutManager := &rolloutmanagerv1alpha1.RolloutManager{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-rollout-manager", + Namespace: "openshift-gitops", + }, + } + Expect(k8sClient.Create(ctx, rolloutManager)).To(Succeed()) + + By("waiting for Argo Rollouts deployment to be created and become available") + depl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts", Namespace: "openshift-gitops"}} + Eventually(depl, "2m", "2s").Should(k8sFixture.ExistByName()) + + By("verifying Argo Rollouts Secret has the custom labels") + labelKey := "operator.argoproj.io/tracked-by" + labelValue := "argocd" + secret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-notification-secret", Namespace: "openshift-gitops"}} + Eventually(secret, "2m", "1s").Should(k8sFixture.ExistByName()) + Expect(secret.Labels).Should(HaveKeyWithValue(labelKey, labelValue)) + + By("verifying Argo Rollouts ConfigMap has the custom labels") + configMap := &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-config", Namespace: "openshift-gitops"}} + Eventually(configMap, "2m", "1s").Should(k8sFixture.ExistByName()) + Expect(configMap.Labels).Should(HaveKeyWithValue(labelKey, labelValue)) + + By("updating RolloutManager spec") + + // Add a new label to trigger reconciliation + if rolloutManager.ObjectMeta.Labels == nil { + rolloutManager.ObjectMeta.Labels = make(map[string]string) + } + rolloutManager.ObjectMeta.Labels["test-update"] = "true" + patch := client.MergeFrom(rolloutManager.DeepCopy()) + Expect(k8sClient.Patch(ctx, rolloutManager, patch)).To(Succeed()) + + By("ensures that custom labels persist in configmap after RolloutManager updates") + configMap = &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-config", Namespace: "openshift-gitops"}} + Eventually(configMap, "2m", "1s").Should(k8sFixture.ExistByName()) + Expect(configMap.Labels).Should(HaveKeyWithValue(labelKey, labelValue)) + + By("ensures that custom labels persist in secret after RolloutManager updates") + secret = &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "argo-rollouts-notification-secret", Namespace: "openshift-gitops"}} + Eventually(secret, "2m", "1s").Should(k8sFixture.ExistByName()) + Expect(secret.Labels).Should(HaveKeyWithValue(labelKey, labelValue)) + }) + + }) +})