From 3f3d78614a1f08f2dc005c523b4ffc9a5800b409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Mon, 18 Mar 2024 08:41:42 +0100 Subject: [PATCH] Add an option to always exit with status zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is for Openshift as it will always restart jobs that fail: https://docs.openshift.com/container-platform/4.15/nodes/jobs/nodes-nodes-jobs.html#jobs-limits_nodes-nodes-jobs Signed-off-by: Aurélien Bompard --- mirrormanager2/crawler/cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mirrormanager2/crawler/cli.py b/mirrormanager2/crawler/cli.py index 96e36cfad..60a904dc3 100755 --- a/mirrormanager2/crawler/cli.py +++ b/mirrormanager2/crawler/cli.py @@ -132,6 +132,12 @@ def validate_continents(ctx, param, value): default=False, help="enable printing of debug-level messages", ) +@click.option( + "--no-fail", + is_flag=True, + default=False, + help="Always exit with status code zero", +) @click.pass_context def main(ctx, config, debug, include_disabled, categories, startid, stopid, fraction, **kwargs): ctx.ensure_object(dict) @@ -228,6 +234,8 @@ def run_on_all_hosts(ctx_obj, options, report): duration = human_duration(time.monotonic() - starttime) if error is None: click.echo(f"Crawler finished after {duration}") + elif options["no-fail"]: + click.echo(f"Crawler failed after {duration}: {error}") else: raise click.ClickException(f"Crawler failed after {duration}: {error}")