From 9d93de6b7fd74d50bf94a63392310288868d52a2 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Wed, 10 Sep 2025 11:10:10 +1000 Subject: [PATCH 1/3] wait_for_job_completion: handle DEFERRED job statuses (bug 1986917) --- lando_cli/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lando_cli/cli.py b/lando_cli/cli.py index 216c710..12e0033 100644 --- a/lando_cli/cli.py +++ b/lando_cli/cli.py @@ -167,6 +167,8 @@ def wait_for_job_completion( click.echo("Job has been submitted and will be started soon.") elif status == "IN_PROGRESS": click.echo("Job is in progress.") + elif status == "DEFERRED": + click.echo("Job was deferred and will be retried.") elif status == "FAILED": error_details = result.get("error", "No additional details provided.") click.secho(f"Job {job_id} failed!", fg="red", bold=True) From 20c5d320a4561ae7ddb1d4c1578899b47523b1dd Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Wed, 10 Sep 2025 11:22:28 +1000 Subject: [PATCH 2/3] wait_for_job_completion: show error that led to deferral (bug 1986917) --- lando_cli/cli.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lando_cli/cli.py b/lando_cli/cli.py index 12e0033..f6050f7 100644 --- a/lando_cli/cli.py +++ b/lando_cli/cli.py @@ -148,7 +148,10 @@ def post_actions( def wait_for_job_completion( - config: Config, job_id: int, poll_interval: int = 3 + config: Config, + job_id: int, + poll_interval: int = 3, + previous_status: str | None = None, ) -> dict: """Wait for a job to complete.""" click.echo("Waiting for job completion, you may exit at any time.") @@ -168,7 +171,14 @@ def wait_for_job_completion( elif status == "IN_PROGRESS": click.echo("Job is in progress.") elif status == "DEFERRED": - click.echo("Job was deferred and will be retried.") + if previous_status != "DEFERRED": + error_details = result.get("error", "No additional details provided.") + click.secho( + f"Job {job_id} was deferred, and will be retried.", fg="yellow" + ) + click.echo(error_details) + else: + click.echo("Job was deferred and will be retried.") elif status == "FAILED": error_details = result.get("error", "No additional details provided.") click.secho(f"Job {job_id} failed!", fg="red", bold=True) @@ -730,4 +740,5 @@ def check_job(config: Config, job_id: int): Example: $ lando check-job 1 """ - wait_for_job_completion(config, job_id) + status = None + status = wait_for_job_completion(config, job_id, status) From e68c1362d3286cdf48d7e802f0f870104bf1875d Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Wed, 10 Sep 2025 11:24:42 +1000 Subject: [PATCH 3/3] fixup! wait_for_job_completion: show error that led to deferral (bug 1986917) --- lando_cli/cli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lando_cli/cli.py b/lando_cli/cli.py index f6050f7..23d858a 100644 --- a/lando_cli/cli.py +++ b/lando_cli/cli.py @@ -151,7 +151,6 @@ def wait_for_job_completion( config: Config, job_id: int, poll_interval: int = 3, - previous_status: str | None = None, ) -> dict: """Wait for a job to complete.""" click.echo("Waiting for job completion, you may exit at any time.") @@ -161,6 +160,8 @@ def wait_for_job_completion( + "to check the status later." ) + previous_status = None + while True: result = get_job_status(config, job_id) @@ -199,6 +200,8 @@ def wait_for_job_completion( time.sleep(poll_interval) + previous_status = status + return result @@ -740,5 +743,4 @@ def check_job(config: Config, job_id: int): Example: $ lando check-job 1 """ - status = None - status = wait_for_job_completion(config, job_id, status) + wait_for_job_completion(config, job_id)