Skip to content

Commit 7461774

Browse files
authored
fix: missing olm.operatorNamespace annotation (#2803)
Signed-off-by: jjaruszewski <jjaruszewski@man.poznan.pl>
1 parent 395bb86 commit 7461774

9 files changed

Lines changed: 20 additions & 7 deletions

File tree

internal/operator-controller/rukpak/render/registryv1/generators/generators.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var certVolumeConfigs = []certVolumeConfig{
5959
// BundleCSVDeploymentGenerator generates all deployments defined in rv1's cluster service version (CSV). The generated
6060
// resource aim to have parity with OLMv0 generated Deployment resources:
6161
// - olm.targetNamespaces annotation is set with the opts.TargetNamespace value
62+
// - olm.operatorNamespace annotation is set with the opts.InstallNamespace value
6263
// - the deployment spec's revision history limit is set to 1
6364
// - merges csv annotations to the deployment template's annotations
6465
func BundleCSVDeploymentGenerator(rv1 *bundle.RegistryV1, opts render.Options) ([]client.Object, error) {
@@ -78,10 +79,13 @@ func BundleCSVDeploymentGenerator(rv1 *bundle.RegistryV1, opts render.Options) (
7879
// See https://github.com/operator-framework/operator-lifecycle-manager/blob/dfd0b2bea85038d3c0d65348bc812d297f16b8d2/pkg/controller/install/deployment.go#L142
7980
annotations := util.MergeMaps(rv1.CSV.Annotations, depSpec.Spec.Template.Annotations)
8081

81-
// In OLMv0 CSVs are annotated with the OperatorGroup's .spec.targetNamespaces
82+
// In OLMv0, CSVs are annotated with OperatorGroup information:
83+
// - olm.targetNamespaces: the OperatorGroup's .spec.targetNamespaces
84+
// - olm.operatorNamespace: the namespace where the OperatorGroup is defined (operator's install namespace)
8285
// See https://github.com/operator-framework/operator-lifecycle-manager/blob/dfd0b2bea85038d3c0d65348bc812d297f16b8d2/pkg/controller/operators/olm/operatorgroup.go#L279
83-
// When the CSVs annotations are copied to the deployment template's annotations, they bring with it this annotation
86+
// When the CSVs annotations are copied to the deployment template's annotations, they bring with it these annotations
8487
annotations["olm.targetNamespaces"] = strings.Join(opts.TargetNamespaces, ",")
88+
annotations["olm.operatorNamespace"] = opts.InstallNamespace
8589
depSpec.Spec.Template.Annotations = annotations
8690

8791
// Hardcode the deployment with RevisionHistoryLimit=1 to maintain parity with OLMv0 behaviour.

internal/operator-controller/rukpak/render/registryv1/generators/generators_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ func Test_BundleCSVDeploymentGenerator_Succeeds(t *testing.T) {
123123
Template: corev1.PodTemplateSpec{
124124
ObjectMeta: metav1.ObjectMeta{
125125
Annotations: map[string]string{
126-
"csv": "annotation",
127-
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
128-
"pod": "annotation",
126+
"csv": "annotation",
127+
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
128+
"olm.operatorNamespace": "install-namespace",
129+
"pod": "annotation",
129130
},
130131
},
131132
Spec: corev1.PodSpec{
@@ -148,8 +149,9 @@ func Test_BundleCSVDeploymentGenerator_Succeeds(t *testing.T) {
148149
Template: corev1.PodTemplateSpec{
149150
ObjectMeta: metav1.ObjectMeta{
150151
Annotations: map[string]string{
151-
"csv": "annotation",
152-
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
152+
"csv": "annotation",
153+
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
154+
"olm.operatorNamespace": "install-namespace",
153155
},
154156
},
155157
},

test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/all-namespaces/11_deployment_argocd-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ spec:
144144
containerImage: quay.io/argoprojlabs/argocd-operator@sha256:99aeec24cc406d06d18822347d9ac3ed053a702d8419191e4e681075fed7b9bb
145145
description: Argo CD is a declarative, GitOps continuous delivery tool for
146146
Kubernetes.
147+
olm.operatorNamespace: argocd-system
147148
olm.targetNamespaces: ""
148149
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
149150
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/own-namespace/09_deployment_argocd-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ spec:
144144
containerImage: quay.io/argoprojlabs/argocd-operator@sha256:99aeec24cc406d06d18822347d9ac3ed053a702d8419191e4e681075fed7b9bb
145145
description: Argo CD is a declarative, GitOps continuous delivery tool for
146146
Kubernetes.
147+
olm.operatorNamespace: argocd-system
147148
olm.targetNamespaces: argocd-system
148149
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
149150
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/single-namespace/09_deployment_argocd-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ spec:
144144
containerImage: quay.io/argoprojlabs/argocd-operator@sha256:99aeec24cc406d06d18822347d9ac3ed053a702d8419191e4e681075fed7b9bb
145145
description: Argo CD is a declarative, GitOps continuous delivery tool for
146146
Kubernetes.
147+
olm.operatorNamespace: argocd-system
147148
olm.targetNamespaces: argocd-watch
148149
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
149150
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-deploymentconfig-options/11_deployment_argocd-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ spec:
148148
description: Argo CD is a declarative, GitOps continuous delivery tool for
149149
Kubernetes.
150150
foo: bar
151+
olm.operatorNamespace: argocd-system
151152
olm.targetNamespaces: ""
152153
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
153154
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/11_deployment_argocd-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ spec:
144144
containerImage: quay.io/argoprojlabs/argocd-operator@sha256:99aeec24cc406d06d18822347d9ac3ed053a702d8419191e4e681075fed7b9bb
145145
description: Argo CD is a declarative, GitOps continuous delivery tool for
146146
Kubernetes.
147+
olm.operatorNamespace: argocd-system
147148
olm.targetNamespaces: ""
148149
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
149150
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/11_deployment_argocd-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ spec:
144144
containerImage: quay.io/argoprojlabs/argocd-operator@sha256:99aeec24cc406d06d18822347d9ac3ed053a702d8419191e4e681075fed7b9bb
145145
description: Argo CD is a declarative, GitOps continuous delivery tool for
146146
Kubernetes.
147+
olm.operatorNamespace: argocd-system
147148
olm.targetNamespaces: ""
148149
operators.operatorframework.io/builder: operator-sdk-v1.10.0+git
149150
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

test/regression/convert/testdata/expected-manifests/webhook-operator.v0.0.5/all-webhook-types/05_deployment_webhook-operator-controller-manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ spec:
4747
]
4848
capabilities: Basic Install
4949
kubectl.kubernetes.io/default-container: manager
50+
olm.operatorNamespace: webhook-system
5051
olm.targetNamespaces: ""
5152
operators.operatorframework.io/builder: operator-sdk-v1.41.1
5253
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4

0 commit comments

Comments
 (0)