feat(jobs): fail the run when a registry image can't be pulled instead of using a local copy
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-07-24 14:12:22 +02:00
parent f0caacd696
commit e8b5dcfd5b
2 changed files with 28 additions and 17 deletions
+14 -11
View File
@@ -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),
+14 -6
View File
@@ -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) =>