Skip to content

Commit 2a654eb

Browse files
authored
run packagemanifests: change default install mode to AllNamespaces (#3663)
1 parent 4739c1f commit 2a654eb

File tree

7 files changed

+47
-19
lines changed

7 files changed

+47
-19
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
entries:
2+
- description: Default install mode for `run packagemanifests` changed from `OwnNamespace` to `AllNamespaces`
3+
kind: change
4+
breaking: true
5+
migration:
6+
header: Default install mode for `run packagemanifests` changed from `OwnNamespace` to `AllNamespaces`
7+
body: >
8+
By default all operators are scaffolded to run at the cluster scope and watch
9+
all namespaces.
10+
11+
However, if you are relying on the default behavior of the `run packagemanifests`
12+
command to use the default `OwnNamespace` install mode, you must now specify it
13+
explicitly with `--install-mode=OwnNamespace`.

hack/tests/integration.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ TMPDIR="$(mktemp -d -p /tmp memcached-operator-XXXX)"
1010
trap_add 'rm -rf $TMPDIR' EXIT
1111
pushd "$TMPDIR"
1212

13+
###########################################################################
14+
### DO NOT UNCOMMENT THESE LINES UNLESS YOU KNOW WHAT YOU'RE DOING !!!! ###
15+
### ###
16+
### They cause the integration image not to be loaded into kind in ###
17+
### TravisCI. ###
18+
### ###
19+
###########################################################################
20+
###
21+
### #prepare_staging_dir $tmp_sdk_root
22+
### #fetch_envtest_tools $tmp_sdk_root
23+
###
24+
###########################################################################
1325
setup_envs $tmp_sdk_root
1426

1527
header_text "Initializing test project"

internal/olm/operator/operator_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (c *OperatorCmd) AddToFlagSet(fs *pflag.FlagSet) {
9393

9494
func (c *OperatorCmd) validate() error {
9595
if c.InstallMode != "" {
96-
if _, _, err := parseInstallModeKV(c.InstallMode); err != nil {
96+
if _, _, err := parseInstallModeKV(c.InstallMode, c.Namespace); err != nil {
9797
return err
9898
}
9999
}

internal/olm/operator/packagemanifests_manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ func (c *PackageManifestsCmd) newManager() (m *packageManifestsManager, err erro
6363

6464
// Handle installModes.
6565
if c.InstallMode == "" {
66-
// Default to OwnNamespace.
67-
m.installMode = operatorsv1alpha1.InstallModeTypeOwnNamespace
68-
m.targetNamespaces = []string{m.namespace}
66+
// Default to AllNamespaces.
67+
m.installMode = operatorsv1alpha1.InstallModeTypeAllNamespaces
68+
m.targetNamespaces = []string{}
6969
} else {
70-
m.installMode, m.targetNamespaces, err = parseInstallModeKV(c.InstallMode)
70+
m.installMode, m.targetNamespaces, err = parseInstallModeKV(c.InstallMode, m.namespace)
7171
if err != nil {
7272
return nil, err
7373
}

internal/olm/operator/tenancy.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ func installModeCompatible(csv *olmapiv1alpha1.ClusterServiceVersion, installMod
5454

5555
// parseInstallModeKV parses an installMode string of the format
5656
// installModeFormat.
57-
func parseInstallModeKV(raw string) (olmapiv1alpha1.InstallModeType, []string, error) {
57+
func parseInstallModeKV(raw, operatorNs string) (olmapiv1alpha1.InstallModeType, []string, error) {
5858
modeSplit := strings.Split(raw, "=")
5959
if allNs := string(olmapiv1alpha1.InstallModeTypeAllNamespaces); raw == allNs || modeSplit[0] == allNs {
6060
return olmapiv1alpha1.InstallModeTypeAllNamespaces, nil, nil
6161
}
62+
if ownNs := string(olmapiv1alpha1.InstallModeTypeOwnNamespace); raw == ownNs || modeSplit[0] == ownNs {
63+
return olmapiv1alpha1.InstallModeTypeOwnNamespace, []string{operatorNs}, nil
64+
}
6265
if len(modeSplit) != 2 {
6366
return "", nil, fmt.Errorf("installMode string %q is malformatted, must be: %s", raw, installModeFormat)
6467
}

test/integration/operator_olm_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ func TestOLMIntegration(t *testing.T) {
5555
}
5656

5757
t.Run("PackageManifestsBasic", PackageManifestsBasic)
58-
t.Run("PackageManifestsAllNamespaces", PackageManifestsAllNamespaces)
58+
t.Run("PackageManifestsOwnNamespace", PackageManifestsOwnNamespace)
5959
t.Run("PackageManifestsMultiplePackages", PackageManifestsMultiplePackages)
6060
}
6161

62-
func PackageManifestsAllNamespaces(t *testing.T) {
62+
func PackageManifestsOwnNamespace(t *testing.T) {
6363

6464
csvConfig := CSVTemplateConfig{
6565
OperatorName: defaultOperatorName,
@@ -77,10 +77,10 @@ func PackageManifestsAllNamespaces(t *testing.T) {
7777
},
7878
},
7979
InstallModes: []operatorsv1alpha1.InstallMode{
80-
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: false},
80+
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: true},
8181
{Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: false},
8282
{Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, Supported: false},
83-
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true},
83+
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: false},
8484
},
8585
}
8686
tmp, cleanup := mkTempDirWithCleanup(t, "")
@@ -104,7 +104,7 @@ func PackageManifestsAllNamespaces(t *testing.T) {
104104
OperatorCmd: operator.OperatorCmd{
105105
KubeconfigPath: kubeconfigPath,
106106
Timeout: defaultTimeout,
107-
InstallMode: string(operatorsv1alpha1.InstallModeTypeAllNamespaces),
107+
InstallMode: string(operatorsv1alpha1.InstallModeTypeOwnNamespace),
108108
},
109109
ManifestsDir: manifestsDir,
110110
Version: defaultOperatorVersion,
@@ -138,10 +138,10 @@ func PackageManifestsBasic(t *testing.T) {
138138
},
139139
},
140140
InstallModes: []operatorsv1alpha1.InstallMode{
141-
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: true},
141+
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: false},
142142
{Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: false},
143143
{Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, Supported: false},
144-
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: false},
144+
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true},
145145
},
146146
}
147147
tmp, cleanup := mkTempDirWithCleanup(t, "")
@@ -205,10 +205,10 @@ func PackageManifestsMultiplePackages(t *testing.T) {
205205
},
206206
},
207207
InstallModes: []operatorsv1alpha1.InstallMode{
208-
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: true},
208+
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: false},
209209
{Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: false},
210210
{Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, Supported: false},
211-
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: false},
211+
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true},
212212
},
213213
},
214214
{
@@ -228,10 +228,10 @@ func PackageManifestsMultiplePackages(t *testing.T) {
228228
},
229229
},
230230
InstallModes: []operatorsv1alpha1.InstallMode{
231-
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: true},
231+
{Type: operatorsv1alpha1.InstallModeTypeOwnNamespace, Supported: false},
232232
{Type: operatorsv1alpha1.InstallModeTypeSingleNamespace, Supported: false},
233233
{Type: operatorsv1alpha1.InstallModeTypeMultiNamespace, Supported: false},
234-
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: false},
234+
{Type: operatorsv1alpha1.InstallModeTypeAllNamespaces, Supported: true},
235235
},
236236
},
237237
}

website/content/en/docs/olm-integration/testing-deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Let's look at the anatomy of the `run packagemanifests` (which is the same for `
3333
- The `InstallModeType` string passed must be marked as "supported" in the CSV being installed.
3434
The namespaces passed must exist or be created by passing a `Namespace` manifest to IncludePaths.
3535
- This option understands the following strings (assuming your CSV does as well):
36-
- `OwnNamespace`: the Operator will watch its own namespace (from **namespace** or the kubeconfig default). This is the default.
36+
- `AllNamespaces`: the Operator will watch all namespaces (cluster-scoped Operators). This is the default.
37+
- `OwnNamespace`: the Operator will watch its own namespace (from **namespace** or the kubeconfig default).
3738
- `SingleNamespace="my-ns"`: the Operator will watch a namespace, not necessarily its own.
38-
- `AllNamespaces=""`: the Operator will watch all namespaces (cluster-scoped Operators).
3939
- **timeout**: a time string dictating the maximum time that `run` can run. The command will
4040
return an error if the timeout is exceeded.
4141

0 commit comments

Comments
 (0)