From e8b5dcfd5b649db4960f446646a58ea6b9418aad Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 24 Jul 2026 14:12:22 +0200 Subject: [PATCH] feat(jobs): fail the run when a registry image can't be pulled instead of using a local copy --- .../src/main/inse/background_jobs/runner.py | 25 +++++++++++-------- webapp/src/app/modules/jobs/jobs.component.ts | 20 ++++++++++----- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/service/src/main/inse/background_jobs/runner.py b/service/src/main/inse/background_jobs/runner.py index 60d13a3c..e0892ad2 100644 --- a/service/src/main/inse/background_jobs/runner.py +++ b/service/src/main/inse/background_jobs/runner.py @@ -151,15 +151,8 @@ def registry_auth() -> Optional[dict[str, str]]: def pull_image(image: str) -> None: - try: - get_docker_client().images.pull(image, auth_config=registry_auth()) - logger.info("Pulled image '%s' from the registry.", image) - except Exception: - logger.warning( - "Could not pull image '%s'; using the local copy if present.", - image, - exc_info=True, - ) + get_docker_client().images.pull(image, auth_config=registry_auth()) + logger.info("Pulled image '%s' from the registry.", image) def start_run( @@ -180,9 +173,19 @@ def start_run( session.refresh(run) return run - try: - if settings.background_jobs_pull_before_run: + if settings.background_jobs_pull_before_run and is_registry_image(image): + try: pull_image(image) + except Exception as error: # noqa: BLE001 + run.status = JobRunStatus.FAILED + run.finished_at = utcnow() + run.logs = f"failed to pull image '{image}': {error}" + session.add(run) + session.commit() + session.refresh(run) + return run + + try: container = get_docker_client().containers.run( image=image, command=resolve_command(definition), diff --git a/webapp/src/app/modules/jobs/jobs.component.ts b/webapp/src/app/modules/jobs/jobs.component.ts index ccf3e90c..97a53644 100644 --- a/webapp/src/app/modules/jobs/jobs.component.ts +++ b/webapp/src/app/modules/jobs/jobs.component.ts @@ -291,16 +291,24 @@ export class JobsComponent implements OnInit { this.backgroundJobsService.runBackgroundJobTask(task.id).subscribe({ next: (run) => { + const status = run.status ?? 'running'; this.updateTask(task.id, (current) => ({ ...current, - status: 'running', + status, last_run: run, })); - this.snackBar.open(`„${task.name}“ wurde gestartet.`, 'OK', { - duration: 3000, - horizontalPosition: 'center', - verticalPosition: 'bottom', - }); + if (status === 'failed') { + this.showError( + `„${task.name}“ ist fehlgeschlagen — Details in den Logs.`, + ); + this.refreshRegistryHealth(); + } else { + this.snackBar.open(`„${task.name}“ wurde gestartet.`, 'OK', { + duration: 3000, + horizontalPosition: 'center', + verticalPosition: 'bottom', + }); + } this.refreshTasks(); }, error: (error) =>