Skip to content

Add automatic retry on machine ID conflict#47

Merged
keyaray merged 1 commit into
mainfrom
retry-after-id-conflict
Jul 24, 2025
Merged

Add automatic retry on machine ID conflict#47
keyaray merged 1 commit into
mainfrom
retry-after-id-conflict

Conversation

@LukasK32

@LukasK32 LukasK32 commented Jul 22, 2025

Copy link
Copy Markdown
Member

Description

When deploying a large count of machines at the same time (e.g. large cluster in Rancher), Proxmox can return the same "next ID" multiple times, and only one deployment will succeed. Rancher will retry deployment, but it takes a long time (there is no ID set in that case so Rancher tries to remove non-existing VM multiple times first).

How Has This Been Tested?

You can force specific ID to be set for the new machine like so:

--- i/cmd/docker-machine-driver-pve/driver/pve.go
+++ w/cmd/docker-machine-driver-pve/driver/pve.go
@@ -31,6 +31,7 @@ func (d *Driver) createPVEVirtualMachine(ctx context.Context) (int, error) {
                Name: d.MachineName,
                Pool: d.ResourcePoolName,
                Full: 0,
+               NewID: 108,
        })
        if err != nil {
                return vmid, fmt.Errorf("failed to clone template ID='%d': %w", d.TemplateID, err)

I created a machine with 108 first, then started creation of a second one, waited for retires to start and removed the initial machine - the driver created the new machine correctly.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@LukasK32 LukasK32 self-assigned this Jul 22, 2025
@LukasK32 LukasK32 force-pushed the retry-after-id-conflict branch from f1cf3aa to fed7b44 Compare July 22, 2025 12:45
@LukasK32 LukasK32 marked this pull request as ready for review July 22, 2025 12:48
@LukasK32 LukasK32 requested a review from keyaray July 22, 2025 12:48
Signed-off-by: Lukas Kirylak <lukas@stellatarum.com>
@LukasK32 LukasK32 force-pushed the retry-after-id-conflict branch from fed7b44 to 7b16828 Compare July 22, 2025 13:23

@keyaray keyaray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@keyaray keyaray merged commit b21e367 into main Jul 24, 2025
7 checks passed
@keyaray keyaray deleted the retry-after-id-conflict branch July 24, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants