Skip to content

Commit 50ea3b0

Browse files
authored
Add operator_namespace to uninstall_operator (#214)
1 parent d929c5b commit 50ea3b0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ocp_utilities/operators.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,28 @@ def install_operator(
182182
)
183183

184184

185-
def uninstall_operator(admin_client, name, timeout=TIMEOUT_30MIN):
185+
def uninstall_operator(
186+
admin_client,
187+
name,
188+
timeout=TIMEOUT_30MIN,
189+
operator_namespace=None,
190+
):
186191
"""
187192
Uninstall operator on cluster.
188193
189194
Args:
190195
admin_client (DynamicClient): Cluster client.
191196
name (str): Name of the operator to uninstall.
192197
timeout (int): Timeout in seconds to wait for operator to be uninstalled.
198+
operator_namespace (str, optional): Operator namespace, if not provided, operator name will be used
193199
"""
194200

195201
csv_name = None
202+
operator_namespace = operator_namespace or name
196203
subscription = Subscription(
197204
client=admin_client,
198205
name=name,
199-
namespace=name,
206+
namespace=operator_namespace,
200207
)
201208
if subscription.exists:
202209
csv_name = subscription.instance.status.installedCSV
@@ -205,13 +212,13 @@ def uninstall_operator(admin_client, name, timeout=TIMEOUT_30MIN):
205212
OperatorGroup(
206213
client=admin_client,
207214
name=name,
208-
namespace=name,
215+
namespace=operator_namespace,
209216
).clean_up()
210217

211218
for _operator in Operator.get(dyn_client=admin_client):
212219
if _operator.name.startswith(name):
213220
# operator name convention is <name>.<namespace>
214-
namespace = name.split(".")[-1]
221+
namespace = operator_namespace or name.split(".")[-1]
215222
ns = Namespace(client=admin_client, name=namespace)
216223
if ns.exists:
217224
ns.clean_up()

0 commit comments

Comments
 (0)