Skip to content

Conversation

@pavel-z1
Copy link
Contributor

Fix HA VM Migration Race Condition

This pull request resolves a race condition that occurs when migrating High Availability (HA) virtual machines.

The Problem

When a Terraform plan modifies the target_node of a proxmox_vm_qemu resource with HA enabled, the provider initiates a migration. However, it would then immediately attempt to apply further configuration updates to the VM on the new node.

Due to cluster synchronization delays, the VM's configuration file might not be immediately available on the destination node, or the VM might still be locked by the migration process. This resulted in intermittent errors, such as:

  • 500 Configuration file 'nodes/...' does not exist
  • 500 VM is locked (migrate)

This pull request addresses issue #1343.

The Solution

To ensure the provider waits until the migration is fully complete, this change introduces a robust polling mechanism. After initiating a migration, the provider will now:

  1. Poll the cluster status until the VM is reported as being on the correct destination node.
  2. Once the VM is on the target node, continue polling until the migration lock (lock: migrate) is released from the VM's status.

This ensures that the provider only proceeds with subsequent configuration updates after the Proxmox cluster has fully finalized the migration and the VM is ready for new commands. A generous 10-minute timeout has been implemented to accommodate large or slow migrations.

@Tinyblargon Tinyblargon self-requested a review October 23, 2025 19:25
@Tinyblargon Tinyblargon added type/enhancement An improvement of existing functionality modifies/go Pull requests that update Go code size/M Denotes a PR that changes 30-99 lines, ignoring generated files test/needen This PR has to be tested labels Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

modifies/go Pull requests that update Go code size/M Denotes a PR that changes 30-99 lines, ignoring generated files test/needen This PR has to be tested type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants