project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Feature] Planned Failover: promote an existing replication-seeded target VM instead of migrating

Open Br00dkast opened this issue 2 months ago • 4 comments

Hey there! 👋 Thanks for taking the time to report this bug — we appreciate it!

Please keep in mind: PegaProx is developed and maintained entirely by volunteers in our free time. We do our best, but we can't work magic 🪄 — please be patient, we'll get to your issue as soon as we can.

Want to help keep PegaProx alive?

  • ⭐ [Star the project](https://github.com/PegaProx/project-pegaprox) — it's free and helps a lot!
  • 💖 [Become a Sponsor](https://pegaprox.com/#sponsor) — helps us dedicate more time to development
  • 🤝 Contributing code or docs is always welcome too!

Describe the bug

Planned Failover does not work for a protected VM when the VM has already been replicated to the target cluster.

The VM is protected using cross-cluster replication and VMID 100 already exists on the target cluster as the replicated standby VM.

When attempting a Planned Failover, PegaProx aborts with:

Target VMID 100 already exists on '6d69d991' (likely pre-seeded by replication). Live/planned migration cannot reconcile an existing VMID — use Emergency Failover to start the replicated target instead.

However, this target VM is expected to exist because it was created by the replication job.

This makes Planned Failover unusable for an already protected/replicated VM.

Emergency Failover works around the existing target VM, but it is not equivalent to Planned Failover. For a planned maintenance or controlled migration, I would expect PegaProx to gracefully stop the source VM, perform a final synchronization, and then promote/start the existing replica on the target cluster.

Steps to Reproduce

  1. Configure cross-cluster replication for a VM.
  2. Allow the replication job to complete successfully so the same VMID exists on the target cluster as a replicated standby VM.
  3. Verify the VM is present on both clusters.
  4. Initiate a Planned Failover for the protected VM.
  5. Planned Failover immediately aborts because the VMID already exists on the target cluster.

Expected behavior

Planned Failover should recognize that the existing target VM is the replica belonging to the protected VM and use it as part of the failover process.

Expected flow would be approximately:

  1. Pause/disable scheduled replication for the VM.
  2. Gracefully shut down the source VM.
  3. Perform a final replication/synchronization.
  4. Verify the replicated target is current.
  5. Promote the existing replicated VM on the target cluster.
  6. Start the VM on the target cluster.
  7. Update the protection/failover state accordingly.

An existing target VM that is known to belong to the replication job should therefore not cause Planned Failover to abort.

If the existing target VM cannot be verified as belonging to the protection/replication job, then refusing to overwrite it would of course be correct.

Environment

  • PegaProx Version: 1.1.1
  • Installation Method: Docker
  • OS: debian 13
  • Browser: Chrome
  • Behind Reverse Proxy?
  • UI?

Logs

Target VMID 100 already exists on '6d69d991' (likely pre-seeded by replication). Live/planned migration cannot reconcile an existing VMID — use Emergency Failover to start the replicated target instead.

The target VM already exists because it was created by the configured cross-cluster replication job.

Screenshots

Checklist

  • [ ] I have searched existing issues to make sure this is not a duplicate
  • [ ] I am using the latest version of PegaProx

Br00dkast avatar Sep 10 '26 10:09 Br00dkast

Hi @Br00dkast,

this is by design at the moment, not a misconfiguration on your side. Planned Failover is implemented as a cross-cluster migration, and a migration cannot take over a VMID that already exists on the target - which is exactly what your replication job creates. The pre-flight check that stops you came in with #413, before that it would run the whole transfer and only then fail, so we detect it up front and send you to Emergency Failover instead.

What you describe (stop the source, final sync, promote the existing replica) is a different mode than migrating, we do not have it. It is noted, but I am not putting a date on it.

MrMasterbay avatar Sep 10 '26 10:09 MrMasterbay

Thanks, that clears up the Planned Failover behavior.

I also tested Emergency Failover and noticed a potentially dangerous scenario.

I shut down the source cluster and triggered Emergency Failover. The replicated VM started correctly on the target cluster.

However, when the source cluster came back online, the original VM started there again as well. This resulted in both copies of the same VM running at the same time, creating a split-brain situation.

Is this currently intended behavior?

I understand that the source cannot be fenced while it is unreachable, but I would expect the emergency failover workflow to include some mechanism or recovery state that prevents the original VM from automatically returning to service until an explicit failback or recovery action is performed.

Br00dkast avatar Sep 10 '26 12:09 Br00dkast

No, that is not intended, and it is a fair catch.

You are right that we cannot fence a source we cannot reach. The gap is what happens afterwards: an emergency failover records the plan as completed with a timestamp and that is it. Nothing marks the VM as having been failed over, so when the source cluster comes back there is nothing on our side that notices the same guest is now running in two places. No onboot handling, no reconnect check, nothing — I looked.

Can you open that as its own issue? This ticket is the promote-mode feature request now, and a split-brain after emergency failover is a different and frankly more urgent thing than that. It should not sit under an enhancement label. Nico will want to decide the shape of it since it touches how failover state is meant to work.

https://opencollective.com/pegaprox if you feel like supporting the project — you have found three real ones today.

— MK

mkellermann97 avatar Sep 10 '26 13:09 mkellermann97

Hi

As requested i opened a separate issue for this.

#806

Br00dkast avatar Sep 10 '26 13:09 Br00dkast