diff --git a/ocs_ci/ocs/resources/mcg.py b/ocs_ci/ocs/resources/mcg.py index 83db3060df4..4e5bd8b82f5 100644 --- a/ocs_ci/ocs/resources/mcg.py +++ b/ocs_ci/ocs/resources/mcg.py @@ -861,7 +861,9 @@ def _check_state(): ) assert False - def exec_mcg_cmd(self, cmd, namespace=None, use_yes=False, **kwargs): + def exec_mcg_cmd( + self, cmd, namespace=None, use_yes=False, ignore_error=False, **kwargs + ): """ Executes an MCG CLI command through the noobaa-operator pod's CLI binary @@ -887,12 +889,14 @@ def exec_mcg_cmd(self, cmd, namespace=None, use_yes=False, **kwargs): if use_yes: result = exec_cmd( [f"yes | {constants.NOOBAA_OPERATOR_LOCAL_CLI_PATH} {cmd} {namespace}"], + ignore_error=ignore_error, shell=True, **kwargs, ) else: result = exec_cmd( f"{constants.NOOBAA_OPERATOR_LOCAL_CLI_PATH} {cmd} {namespace}", + ignore_error=ignore_error, **kwargs, ) result.stdout = result.stdout.decode() diff --git a/ocs_ci/ocs/resources/objectbucket.py b/ocs_ci/ocs/resources/objectbucket.py index 82e8187552c..89d5ab00f2d 100644 --- a/ocs_ci/ocs/resources/objectbucket.py +++ b/ocs_ci/ocs/resources/objectbucket.py @@ -383,9 +383,19 @@ def internal_delete(self): NotFoundError: In case the OBC was not found """ - result = self.mcg.exec_mcg_cmd(f"obc delete {self.name}") - if "deleting" and self.name not in result.stderr.lower(): - raise NotFoundError(result) + try: + result = self.mcg.exec_mcg_cmd(f"obc delete {self.name}") + if ( + "deleting" not in result.stderr.lower() + and self.name not in result.stderr.lower() + ): + raise NotFoundError(result) + except CommandFailed as e: + result = self.mcg.exec_mcg_cmd(f"obc delete {self.name}", ignore_error=True) + if f'Not Found: ObjectBucketClaim "{self.name}"' in str( + result.stderr + ) and "does not exist" in str(result.stderr): + raise NotFoundError(e) @property def internal_status(self):