fix(images): idempotent download (skip if file exists) + real failure reason
All checks were successful
Backend Tests / pytest (Python 3.12) (push) Successful in 52s
Deploy to Production / Trigger production update (push) Successful in 8s

Retrying a template build failed at download because the qcow2 from a prior
attempt already existed and download-url refuses to overwrite. Now skip the
download when the volume already exists (volume_exists), and surface the PVE
task-log tail on download failure instead of a generic message.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 00:38:50 +05:00
parent cdb49abf0f
commit f880c9e177
2 changed files with 50 additions and 24 deletions

View File

@@ -119,6 +119,17 @@ class StorageMixin:
logger.error(f"Ошибка загрузки {url} на {node}:{storage}: {e}")
raise
def volume_exists(self, node: str, storage: str, volid: str) -> bool:
"""Проверить, есть ли уже том volid в хранилище (для идемпотентной загрузки)."""
if not self.proxmox:
return False
try:
items = self.proxmox.nodes(node).storage(storage).content.get()
return any(it.get('volid') == volid for it in (items or []))
except Exception as e:
logger.debug(f"volume_exists check failed {storage}/{volid}: {e}")
return False
def get_download_target_storages(self, node: str, content: str) -> List[Dict]:
"""
Получить активные хранилища ноды, поддерживающие указанный тип контента