fix: wait for Proxmox resize task before VM start (v1.2.0)

- configure_vm: capture resize UPID and call wait_for_task(120s)
  before returning; prevents lock conflict when VM is started right
  after disk resize
- resize_vm_disk / resize_container_disk (x2): same fix applied
- remove unnecessary restart_vm() after manual QEMU disk resize —
  resize is a storage-layer operation and does not require a reboot;
  the auto-restart was causing a second lock conflict

Fixes: can't lock file '/var/lock/qemu-server/lock-xxx.conf' - got timeout
Fixes: command '/usr/bin/qemu-img resize' failed: got timeout
This commit is contained in:
markmorado
2026-03-16 20:23:06 +01:00
parent bd1777f67b
commit 4ef79112be
15 changed files with 342 additions and 156 deletions

View File

@@ -512,7 +512,8 @@ def delete_proxmox_server(
):
"""Удалить Proxmox сервер и связанные OS Templates"""
from ...proxmox_client import clear_server_cache
from ...models import OSTemplate, OSTemplateGroup, VMInstance
from ...models import OSTemplate, OSTemplateGroup, VMInstance, Notification
from ...workers import monitoring_worker
server = db.query(ProxmoxServer).filter(ProxmoxServer.id == server_id).first()
if not server:
@@ -558,11 +559,26 @@ def delete_proxmox_server(
logger.info(f"User {current_user.username} deleted Proxmox server: {server_name} ({server_ip})")
# Удаляем уведомления о сервере (offline/online) чтобы они не показывались после удаления
notifications_deleted = db.query(Notification).filter(
Notification.source_id == str(server_id),
Notification.source.in_(["monitoring", "server_monitor"])
).delete(synchronize_session=False)
if notifications_deleted > 0:
logger.info(f"Deleted {notifications_deleted} notifications for server {server_name}")
# Очищаем кеш подключений для этого сервера
clear_server_cache(server_ip)
db.delete(server)
db.commit()
# Очищаем in-memory состояние мониторинга для удалённого сервера
try:
monitoring_worker.cleanup_server_state(server_id)
except Exception as e:
logger.warning(f"Failed to cleanup monitoring state for server {server_id}: {e}")
return None