Skip to content

Commit 8016fbd

Browse files
authored
⚠ OPRUN-4106: remove support for annotation based config (#2224)
* OPRUN-4106: remove support for annotation based config With #2166 and #2163 in place, annotation based config support can be removed. Signed-off-by: Anik Bhattacharjee <anbhatta@redhat.com> * update docs and demo to use new config spec --------- Signed-off-by: Anik Bhattacharjee <anbhatta@redhat.com>
1 parent 9af2eff commit 8016fbd

File tree

7 files changed

+92
-62
lines changed

7 files changed

+92
-62
lines changed

docs/draft/howto/single-ownnamespace-install.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ apiVersion: olm.operatorframework.io/v1
9191
kind: ClusterExtension
9292
metadata:
9393
name: argocd
94-
annotations:
95-
olm.operatorframework.io/watch-namespace: argocd
9694
spec:
9795
namespace: argocd
9896
serviceAccount:

hack/demo/own-namespace-demo-script.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
#
44
# Welcome to the OwnNamespace install mode demo
55
#
6-
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
6+
set -e
7+
trap 'echo "Demo ran into error"; trap - SIGTERM && kill -- -$$; exit 1' ERR SIGINT SIGTERM EXIT
8+
9+
# install experimental CRDs with config field support
10+
kubectl apply -f "$(dirname "${BASH_SOURCE[0]}")/../../manifests/experimental.yaml"
11+
12+
# wait for experimental CRDs to be available
13+
kubectl wait --for condition=established --timeout=60s crd/clusterextensions.olm.operatorframework.io
714

815
# enable 'SingleOwnNamespaceInstallSupport' feature gate
916
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]'
@@ -41,3 +48,27 @@ kubectl get deployments -n argocd-system argocd-operator-controller-manager -o j
4148
# check service account for role binding is the same as controller service-account
4249
rolebinding=$(kubectl get rolebindings -n argocd-system -o name | grep 'argocd-operator' | head -n 1)
4350
kubectl get -n argocd-system $rolebinding -o jsonpath='{.subjects}' | jq .[0]
51+
52+
echo "Demo completed successfully!"
53+
54+
# cleanup resources
55+
echo "Cleaning up demo resources..."
56+
kubectl delete clusterextension argocd-operator --ignore-not-found=true
57+
kubectl delete namespace argocd-system --ignore-not-found=true
58+
kubectl delete clusterrolebinding argocd-installer-crb --ignore-not-found=true
59+
60+
# remove feature gate from deployment
61+
echo "Removing feature gate from operator-controller..."
62+
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "remove", "path": "/spec/template/spec/containers/0/args", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]' || true
63+
64+
# restore standard CRDs
65+
echo "Restoring standard CRDs..."
66+
kubectl apply -f "$(dirname "${BASH_SOURCE[0]}")/../../manifests/base.yaml"
67+
68+
# wait for standard CRDs to be available
69+
kubectl wait --for condition=established --timeout=60s crd/clusterextensions.olm.operatorframework.io
70+
71+
# wait for operator-controller to become available with standard config
72+
kubectl rollout status -n olmv1-system deployment/operator-controller-controller-manager
73+
74+
echo "Demo cleanup completed!"

hack/demo/resources/own-namespace-demo.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ apiVersion: olm.operatorframework.io/v1
22
kind: ClusterExtension
33
metadata:
44
name: argocd-operator
5-
annotations:
6-
# watch namespace is the same as intall namespace
7-
olm.operatorframework.io/watch-namespace: argocd-system
85
spec:
96
namespace: argocd-system
107
serviceAccount:

hack/demo/resources/single-namespace-demo.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ apiVersion: olm.operatorframework.io/v1
22
kind: ClusterExtension
33
metadata:
44
name: argocd-operator
5-
annotations:
6-
# watch-namespace is different from install namespace
7-
olm.operatorframework.io/watch-namespace: argocd
85
spec:
96
namespace: argocd-system
107
serviceAccount:
118
name: argocd-installer
9+
config:
10+
configType: Inline
11+
inline:
12+
watchNamespace: argocd
1213
source:
1314
sourceType: Catalog
1415
catalog:

hack/demo/single-own-namespace-demo-script.sh renamed to hack/demo/single-namespace-demo-script.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
#
44
# Welcome to the SingleNamespace install mode demo
55
#
6-
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
6+
set -e
7+
trap 'echo "Demo ran into error"; trap - SIGTERM && kill -- -$$; exit 1' ERR SIGINT SIGTERM EXIT
8+
9+
# install experimental CRDs with config field support
10+
kubectl apply -f "$(dirname "${BASH_SOURCE[0]}")/../../manifests/experimental.yaml"
11+
12+
# wait for experimental CRDs to be available
13+
kubectl wait --for condition=established --timeout=60s crd/clusterextensions.olm.operatorframework.io
714

815
# enable 'SingleOwnNamespaceInstallSupport' feature gate
916
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]'
@@ -44,3 +51,27 @@ kubectl get deployments -n argocd-system argocd-operator-controller-manager -o j
4451
# check service account for role binding is the controller deployment service account
4552
rolebinding=$(kubectl get rolebindings -n argocd -o name | grep 'argocd-operator' | head -n 1)
4653
kubectl get -n argocd $rolebinding -o jsonpath='{.subjects}' | jq .[0]
54+
55+
echo "Demo completed successfully!"
56+
57+
# cleanup resources
58+
echo "Cleaning up demo resources..."
59+
kubectl delete clusterextension argocd-operator --ignore-not-found=true
60+
kubectl delete namespace argocd-system argocd --ignore-not-found=true
61+
kubectl delete clusterrolebinding argocd-installer-crb --ignore-not-found=true
62+
63+
# remove feature gate from deployment
64+
echo "Removing feature gate from operator-controller..."
65+
kubectl patch deployment -n olmv1-system operator-controller-controller-manager --type='json' -p='[{"op": "remove", "path": "/spec/template/spec/containers/0/args", "value": "--feature-gates=SingleOwnNamespaceInstallSupport=true"}]' || true
66+
67+
# restore standard CRDs
68+
echo "Restoring standard CRDs..."
69+
kubectl apply -f "$(dirname "${BASH_SOURCE[0]}")/../../manifests/base.yaml"
70+
71+
# wait for standard CRDs to be available
72+
kubectl wait --for condition=established --timeout=60s crd/clusterextensions.olm.operatorframework.io
73+
74+
# wait for operator-controller to become available with standard config
75+
kubectl rollout status -n olmv1-system deployment/operator-controller-controller-manager
76+
77+
echo "Demo cleanup completed!"

internal/operator-controller/applier/watchnamespace.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import (
1010
"github.com/operator-framework/operator-controller/internal/operator-controller/features"
1111
)
1212

13-
const (
14-
AnnotationClusterExtensionWatchNamespace = "olm.operatorframework.io/watch-namespace"
15-
)
16-
1713
// GetWatchNamespace determines the watch namespace the ClusterExtension should use
1814
// Note: this is a temporary artifice to enable gated use of single/own namespace install modes
1915
// for registry+v1 bundles. This will go away once the ClusterExtension API is updated to include
@@ -32,8 +28,6 @@ func GetWatchNamespace(ext *ocv1.ClusterExtension) (string, error) {
3228
return "", fmt.Errorf("invalid bundle configuration: %w", err)
3329
}
3430
watchNamespace = cfg.WatchNamespace
35-
} else if _, ok := ext.Annotations[AnnotationClusterExtensionWatchNamespace]; ok {
36-
watchNamespace = ext.Annotations[AnnotationClusterExtensionWatchNamespace]
3731
} else {
3832
return "", nil
3933
}

internal/operator-controller/applier/watchnamespace_test.go

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ func TestGetWatchNamespace(t *testing.T) {
3939
for _, tt := range []struct {
4040
name string
4141
want string
42-
csv *ocv1.ClusterExtension
42+
ce *ocv1.ClusterExtension
4343
expectError bool
4444
}{
4545
{
46-
name: "cluster extension does not configure a watch namespace",
46+
name: "no watch namespace is configured in a ClusterExtension CR",
4747
want: corev1.NamespaceAll,
48-
csv: &ocv1.ClusterExtension{
48+
ce: &ocv1.ClusterExtension{
4949
ObjectMeta: metav1.ObjectMeta{
5050
Name: "extension",
5151
Annotations: nil,
@@ -54,9 +54,9 @@ func TestGetWatchNamespace(t *testing.T) {
5454
},
5555
expectError: false,
5656
}, {
57-
name: "cluster extension configures a watch namespace",
57+
name: "a watch namespace is configured in a ClusterExtension CR",
5858
want: "watch-namespace",
59-
csv: &ocv1.ClusterExtension{
59+
ce: &ocv1.ClusterExtension{
6060
ObjectMeta: metav1.ObjectMeta{
6161
Name: "extension",
6262
},
@@ -71,63 +71,41 @@ func TestGetWatchNamespace(t *testing.T) {
7171
},
7272
expectError: false,
7373
}, {
74-
name: "cluster extension configures a watch namespace through annotation",
75-
want: "watch-namespace",
76-
csv: &ocv1.ClusterExtension{
74+
name: "a watch namespace is configured in a ClusterExtension CR but with invalid namespace",
75+
ce: &ocv1.ClusterExtension{
7776
ObjectMeta: metav1.ObjectMeta{
7877
Name: "extension",
79-
Annotations: map[string]string{
80-
"olm.operatorframework.io/watch-namespace": "watch-namespace",
81-
},
8278
},
83-
},
84-
expectError: false,
85-
}, {
86-
name: "cluster extension configures a watch namespace through annotation with invalid ns",
87-
csv: &ocv1.ClusterExtension{
88-
ObjectMeta: metav1.ObjectMeta{
89-
Name: "extension",
90-
Annotations: map[string]string{
91-
"olm.operatorframework.io/watch-namespace": "watch-namespace-",
92-
},
93-
},
94-
},
95-
expectError: true,
96-
}, {
97-
name: "cluster extension configures a watch namespace through annotation with empty ns",
98-
csv: &ocv1.ClusterExtension{
99-
ObjectMeta: metav1.ObjectMeta{
100-
Name: "extension",
101-
Annotations: map[string]string{
102-
"olm.operatorframework.io/watch-namespace": "",
79+
Spec: ocv1.ClusterExtensionSpec{
80+
Config: &ocv1.ClusterExtensionConfig{
81+
ConfigType: ocv1.ClusterExtensionConfigTypeInline,
82+
Inline: &apiextensionsv1.JSON{
83+
Raw: []byte(`{"watchNamespace":"watch-namespace-"}`),
84+
},
10385
},
10486
},
10587
},
10688
expectError: true,
10789
}, {
108-
name: "cluster extension configures a watch namespace through annotation and config (take config)",
109-
want: "watch-namespace",
110-
csv: &ocv1.ClusterExtension{
90+
name: "a watch namespace is configured in a ClusterExtension CR with an empty string as the namespace",
91+
ce: &ocv1.ClusterExtension{
11192
ObjectMeta: metav1.ObjectMeta{
11293
Name: "extension",
113-
Annotations: map[string]string{
114-
"olm.operatorframework.io/watch-namespace": "dont-use-this-watch-namespace",
115-
},
11694
},
11795
Spec: ocv1.ClusterExtensionSpec{
11896
Config: &ocv1.ClusterExtensionConfig{
11997
ConfigType: ocv1.ClusterExtensionConfigTypeInline,
12098
Inline: &apiextensionsv1.JSON{
121-
Raw: []byte(`{"watchNamespace":"watch-namespace"}`),
99+
Raw: []byte(`{"watchNamespace":""}`),
122100
},
123101
},
124102
},
125103
},
126-
expectError: false,
104+
expectError: true,
127105
}, {
128-
name: "cluster extension configures an invalid watchNamespace: multiple watch namespaces",
106+
name: "an invalid watchNamespace value is configured in a ClusterExtension CR: multiple watch namespaces",
129107
want: "",
130-
csv: &ocv1.ClusterExtension{
108+
ce: &ocv1.ClusterExtension{
131109
ObjectMeta: metav1.ObjectMeta{
132110
Name: "extension",
133111
},
@@ -142,9 +120,9 @@ func TestGetWatchNamespace(t *testing.T) {
142120
},
143121
expectError: true,
144122
}, {
145-
name: "cluster extension configures an invalid watchNamespace: invalid name",
123+
name: "an invalid watchNamespace value is configured in a ClusterExtension CR: invalid name",
146124
want: "",
147-
csv: &ocv1.ClusterExtension{
125+
ce: &ocv1.ClusterExtension{
148126
ObjectMeta: metav1.ObjectMeta{
149127
Name: "extension",
150128
},
@@ -159,9 +137,9 @@ func TestGetWatchNamespace(t *testing.T) {
159137
},
160138
expectError: true,
161139
}, {
162-
name: "cluster extension configures an invalid watchNamespace: invalid json",
140+
name: "an invalid watchNamespace value is configured in a ClusterExtension CR: invalid json",
163141
want: "",
164-
csv: &ocv1.ClusterExtension{
142+
ce: &ocv1.ClusterExtension{
165143
ObjectMeta: metav1.ObjectMeta{
166144
Name: "extension",
167145
},
@@ -178,7 +156,7 @@ func TestGetWatchNamespace(t *testing.T) {
178156
},
179157
} {
180158
t.Run(tt.name, func(t *testing.T) {
181-
got, err := applier.GetWatchNamespace(tt.csv)
159+
got, err := applier.GetWatchNamespace(tt.ce)
182160
require.Equal(t, tt.want, got)
183161
require.Equal(t, tt.expectError, err != nil)
184162
})

0 commit comments

Comments
 (0)