Skip to content

Commit 5059d7f

Browse files
Merge pull request #31 from SomethingGeneric/copilot/prevent-host-reboot-without-snapshots
Prevent host reboots without VM snapshots
2 parents 5abd647 + e34e3d0 commit 5059d7f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

miniupdate/update_automator.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,20 @@ def process_host_automated_update(self, host: Host, timeout: int = 120) -> Autom
308308
logger.info(f"Successfully applied updates on {host.name}")
309309

310310
# Reboot if configured (only for hosts that actually received updates)
311+
# AND only if a snapshot was created (safety requirement)
311312
if self.update_config.get('reboot_after_updates', False):
312-
logger.info(f"Reboot after updates is enabled - proceeding with reboot for {host.name}")
313-
reboot_result = self._handle_reboot_and_verification(
314-
host, vm_mapping, snapshot_name, start_time
315-
)
316-
if reboot_result:
317-
return reboot_result
313+
if snapshot_name:
314+
logger.info(f"Reboot after updates is enabled - proceeding with reboot for {host.name}")
315+
reboot_result = self._handle_reboot_and_verification(
316+
host, vm_mapping, snapshot_name, start_time
317+
)
318+
if reboot_result:
319+
return reboot_result
320+
else:
321+
logger.warning(
322+
f"Reboot after updates is enabled but no snapshot was created for {host.name} - "
323+
f"skipping reboot for safety. Configure Proxmox integration and VM mapping to enable reboots."
324+
)
318325
else:
319326
logger.info(f"Reboot after updates is disabled - skipping reboot for {host.name}")
320327

0 commit comments

Comments
 (0)