@@ -273,6 +273,7 @@ def uninstall_operator(
273
273
name : str ,
274
274
timeout : int = TIMEOUT_30MIN ,
275
275
operator_namespace : str = "" ,
276
+ clean_up_namespace : bool = True ,
276
277
) -> None :
277
278
"""
278
279
Uninstall operator on cluster.
@@ -282,8 +283,8 @@ def uninstall_operator(
282
283
name (str): Name of the operator to uninstall.
283
284
timeout (int): Timeout in seconds to wait for operator to be uninstalled.
284
285
operator_namespace (str, optional): Operator namespace, if not provided, operator name will be used
286
+ clean_up_namespace (bool, optional): Used to decide if operator_namespace should be cleaned up. Defaults to True.
285
287
"""
286
-
287
288
csv_name = None
288
289
operator_namespace = operator_namespace or name
289
290
subscription = Subscription (
@@ -301,13 +302,14 @@ def uninstall_operator(
301
302
namespace = operator_namespace ,
302
303
).clean_up ()
303
304
304
- for _operator in Operator .get (dyn_client = admin_client ):
305
- if _operator .name .startswith (name ):
306
- # operator name convention is <name>.<namespace>
307
- namespace = operator_namespace or name .split ("." )[- 1 ]
308
- ns = Namespace (client = admin_client , name = namespace )
309
- if ns .exists :
310
- ns .clean_up ()
305
+ if clean_up_namespace :
306
+ for _operator in Operator .get (dyn_client = admin_client ):
307
+ if _operator .name .startswith (name ):
308
+ # operator name convention is <name>.<namespace>
309
+ namespace = operator_namespace or name .split ("." )[- 1 ]
310
+ ns = Namespace (client = admin_client , name = namespace )
311
+ if ns .exists :
312
+ ns .clean_up ()
311
313
312
314
if csv_name :
313
315
csv = ClusterServiceVersion (
@@ -316,7 +318,7 @@ def uninstall_operator(
316
318
name = csv_name ,
317
319
)
318
320
319
- csv .wait_deleted (timeout = timeout )
321
+ csv .wait_deleted (timeout = timeout ) if clean_up_namespace else csv . clean_up ( wait = True )
320
322
321
323
322
324
def create_catalog_source_for_iib_install (
0 commit comments