Skip to content

Commit

Permalink
Fix parallel execution handling when returning early (#930)
Browse files Browse the repository at this point in the history
resourceVmQemuCreate and resourceVmQemuUpdate can both return early due to
errors. When this happens, we must ensure that we "unlock" the slot we have
claimed for parallel execution. This is safe to do in a defer action because
even if we manually "unlock" prior to the function return, the unlock action
checks to ensure that the "lock" is held prior to attempting to return a slot
to the pool.
  • Loading branch information
evan-a-a authored Feb 25, 2024
1 parent 35d3afa commit d47b71b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,8 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte

pconf := meta.(*providerConfiguration)
lock := pmParallelBegin(pconf)
// defer lock.unlock()
defer lock.unlock()

client := pconf.Client
vmName := d.Get("name").(string)
vga := d.Get("vga").(*schema.Set)
Expand Down Expand Up @@ -1044,6 +1045,7 @@ func resourceVmQemuUpdate(ctx context.Context, d *schema.ResourceData, meta inte
pconf := meta.(*providerConfiguration)
client := pconf.Client
lock := pmParallelBegin(pconf)
defer lock.unlock()

// create a logger for this function
logger, _ := CreateSubLogger("resource_vm_update")
Expand Down Expand Up @@ -1316,6 +1318,7 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf
pconf := meta.(*providerConfiguration)
lock := pmParallelBegin(pconf)
defer lock.unlock()

client := pconf.Client
// create a logger for this function
var diags diag.Diagnostics
Expand Down

0 comments on commit d47b71b

Please sign in to comment.