Repository navigation
Generate time-plus-random Proxmox VMIDs instead of calling /cluster/nextid - #489
Conversation
Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com>
/cluster/nextid
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches the accepted probabilistic design, with only minor documentation clarifications remaining.
Review effort: Balanced
Findings: 1
What changed in this PR
Replaces Proxmox’s /cluster/nextid calls with locally generated VMIDs to reduce concurrent container-creation conflicts reported in #488.
Changes:
- Adds a time-slot and cryptographic-random VMID generator.
- Connects Proxmox allocation to the generator and adds tests.
- Updates allocation comments and log text without changing Docker behavior.
| File | Description |
|---|---|
create-a-container/utils/vmid.js |
Adds local VMID generation. |
create-a-container/utils/proxmox-api.js |
Replaces the allocation HTTP request. |
create-a-container/utils/__tests__/vmid.test.js |
Tests bounds, randomness, and adjacent-second separation. |
create-a-container/bin/create-container.js |
Updates allocation comments and logging. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const timeSlot = Math.floor(now / 1000) % TIME_SLOTS; | ||
| return VMID_MIN + timeSlot * RANDOM_SPACE + crypto.randomInt(RANDOM_SPACE); |
cmyers-mieweb
left a comment
There was a problem hiding this comment.
Approved, we will need to see how the retry logic added works within the ongoing environment once this is merged to spot for any creation bugs. Only other thing I can think is check logic if the job-runner already has an ID it is using in an ongoing build, though the event in itself after the randomization makes it rare.
|
@copilot resolve merge conlficts |
…-creation-ctid-conflict # Conflicts: # create-a-container/bin/create-container.js # create-a-container/utils/proxmox-api.js Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com>
Resolved the conflicts and merged latest |

Proxmox's
/cluster/nextidendpoint returns the same ID to callers that ask at the same time. When two container-creation jobs run concurrently, both get one ID, and the slowercreateLxccall fails with a CTID conflict.This PR has the manager generate the VMID itself, so no coordination or retries are needed.
Changes
utils/vmid.js(new):generateVmid()builds an ID in the style of UUIDv7, packed into Proxmox's VMID range of 100–999999999:999,899,999.ProxmoxApi.nextId(): returnsgenerateVmid()and no longer makes an HTTP call. Callers don't change.bin/create-container.js: only the comment and log text change.utils/__tests__/vmid.test.jschecks the range bounds, that IDs randomize within one second, and that IDs from different seconds never overlap.Collision properties
Review notes
DummyApiis unchanged.