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

[Bug] Cross-cluster LXC replication fails — wrong clone parameter (name vs hostname)

Open DarmokNoob opened this issue 6 months ago • 4 comments

[!NOTE] The stubbornness to actually prove what I found out with live pvesh tests and pveproxy log captures rather than just making assumptions was all me, but Claude and Gemini get credit for helping me dig through the API docs, documenting the investigation, and the RCA write up.

Important caveat: I was unable to capture the actual POST body sent by PegaProx due to TLS encryption on port 8006 and I don't think I needed to go that far. The conclusion that name is the offending parameter is based on the error message reported by both PegaProx and Proxmox, confirmed by pvesh testing showing name is explicitly rejected as an unknown option for LXC clone while hostname is accepted. If you (the dev team) can inspect the actual clone payload in the source code that should prove my assumptions.

Describe the bug

Every cross-cluster DR replication job targeting an LXC container fails immediately at the clone step with a 400 error:

Clone failed: {"errors":{"name":"property is not defined in schema and the schema does not allow additional properties"},"data":null,"message":"Parameter verification failed.\n"}

The snapshot and vzdelsnapshot steps complete successfully — only the clone step fails. The same error occurs consistently across multiple LXC containers and multiple attempts.

Based on the error message, PegaProx appears to be sending a name parameter in the clone API call. The Proxmox LXC clone API does not accept name — that is a QEMU/VM-only parameter. LXC containers use hostname instead.

Steps to Reproduce

  1. Add two standalone Proxmox nodes as separate clusters in PegaProx
  2. Ensure LXC containers on source node are on lvmthin storage
  3. Open any LXC container → Configure → Replication → Cross-Cluster → Add DR Job
  4. Set target cluster, target storage (lvmthin), schedule
  5. Trigger the job manually

Expected behavior

The LXC container should be cloned to the target cluster successfully.

Suspected Root Cause

The Proxmox API uses different parameters for clone depending on type:

  • QEMU VMs → name
  • LXC containers → hostname The error "name":"property is not defined in schema" suggests PegaProx is sending name for LXC containers, which Proxmox rejects with 400.

Confirmed via direct pvesh testing on Proxmox 8.4.18:

# name is rejected for LXC
pvesh create /nodes/pve-source/lxc/101/clone --newid 901 --storage local-lvm --full 1 --name test
# Unknown option: name
# 400 unable to parse option
 
# hostname is accepted for LXC
pvesh create /nodes/pve-source/lxc/101/clone --newid 901 --storage local-lvm --full 1 --hostname test
# Proceeds past parameter validation — different error unrelated to parameter name

Tested Proof — Correct API Sequence Works

To confirm the fix, the correct API sequence was executed remotely from the root host that the PegaProx Docker container is installed on (10.0.0.1) against the source Proxmox node (10.0.0.2) using curl. Note: curl is not included in the PegaProx Docker image so these commands were run on the host OS directly — same machine, same network path PegaProx uses.

Step 1 — Create snapshot (same as PegaProx does, this already works):

curl -sk -X POST 'https://10.0.0.2:8006/api2/json/nodes/pve-source/lxc/101/snapshot' \
  -H 'Authorization: PVEAPIToken=root@pam!testtoken=<redacted>' \
  -d 'snapname=drtest'

Response:

{"data":"UPID:pve-source:0027660D:02EAFFBD:6A122D4A:vzsnapshot:101:root@pam!testtoken:"}

Step 2 — Clone using hostname instead of name (this is the fix):

curl -sk -X POST 'https://10.0.0.2:8006/api2/json/nodes/pve-source/lxc/101/clone' \
  -H 'Authorization: PVEAPIToken=root@pam!testtoken=<redacted>' \
  -d 'newid=901&hostname=LXC-Container-DR&storage=local-lvm&full=1&snapname=drtest'

Response:

{"data":"UPID:pve-source:002766F0:02EB0BB2:6A122D68:vzclone:101:root@pam!testtoken:"}

No 400 error. The clone task was accepted and executed successfully. The cloned container appeared in PegaProx confirming the operation completed end to end.

These commands were run on the same host and same network path PegaProx uses — the only difference between PegaProx's failing call and this successful call is hostname vs name. That's the fix.

Suggested Fix

In the cross-cluster replication clone code, detect VM type and send the correct parameter:

if vm_type == 'lxc':
    params['hostname'] = vm_name
else:
    params['name'] = vm_name

Environment

  • PegaProx Version: v0.9.10
  • Installation Method: Docker
  • OS: Arch Linux ARM64 (PiKVM, Raspberry Pi 4)
  • Browser: Chrome
  • Behind Reverse Proxy? No
  • UI: Modern Layout

Logs

pveproxy access log on source Proxmox node showing 400 on clone POST:

POST /api2/json/nodes/pve-source/lxc/101/clone HTTP/1.1" 400 164

PegaProx error from DR job:

Clone failed: {"errors":{"name":"property is not defined in schema and the schema does not allow additional properties"},"data":null,"message":"Parameter verification failed.\n"}

Checklist

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

DarmokNoob avatar May 23 '26 23:05 DarmokNoob

Hey @DarmokNoob — confirmed, fixed on Testing. Thanks for the surgical RCA — pvesh + curl proof of the failing payload vs the working one made this a 5-minute fix on our side.

Three call sites had the same bug:

File Function Site
pegaprox/api/vms.py cross-cluster replication (xcrepl) the one in your trace
pegaprox/api/vms.py intra-cluster replication (repl) same shape, would have hit the same wall on LXC
pegaprox/core/manager.py the manual clone-from-UI path also would have failed on LXC

All three now check vm_type == 'lxc' and emit hostname= instead of name=. The QEMU path is unchanged.

if vm_type == 'lxc':
    clone_data['hostname'] = clone_label
else:
    clone_data['name'] = clone_label

Cleanest version of your suggested fix.

Closing as fix-on-Testing. After the next release lands, your cross-cluster LXC DR jobs should clone through to the storage-mapping step without the schema error. If anything else surfaces on the remote-migrate side after the clone, drop another ticket — we'd treat it as a separate issue.

— Marcus

(Donations at https://opencollective.com/pegaprox if cross-cluster LXC DR getting unbroken earns its keep.)

mkellermann97 avatar May 24 '26 09:05 mkellermann97

@DarmokNoob — v0.9.11 is out, all three call sites (xcrepl, intra-cluster repl, manual clone) now send hostname= for LXC. Closing.

— Marcus

mkellermann97 avatar May 24 '26 17:05 mkellermann97

Awesome! Thank you for the quick fix! I'll be sure to let you know how it works out!

DarmokNoob avatar May 24 '26 17:05 DarmokNoob

So that fixed the issue but loaded up a bunch of other finds that i couldn't test till we got the migration working. I have a couple of more bugs to report but the good news is I also came up with some fixes that i tested as a I went so these also should be relatively easy patches.

DarmokNoob avatar May 25 '26 02:05 DarmokNoob