Skip to content

Commit

Permalink
Changing the lock position in resourceSrmNodeDelete
Browse files Browse the repository at this point in the history
TestAccResourceVmcMultipleSrmNodesZerocloud was failing with

 testing_new.go:82: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: task failed: failed to delete SRM node:
com.vmware.skyscraper.common.BadRequestException: Failed to lock site
recovery for sddc id ########

The lock in resourceSrmNodeDelete was after tha actual delete call.
Changed the position of the lock to precede the delete call.

Managed to reproduce the failure of TestAccResourceVmcMultipleSrmNodesZerocloud
before the change

Testing done:

Ran several times  TestAccResourceVmcMultipleSrmNodesZerocloud locally
with success wfter the change

Signed-off-by: Vasil Atanasov <[email protected]>
  • Loading branch information
vasilsatanasov committed Aug 17, 2023
1 parent a3019ae commit 67c5749
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vmc/resource_vmc_srm_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func resourceSrmNodeDelete(d *schema.ResourceData, m interface{}) error {

orgID := (m.(*connector.Wrapper)).OrgID
sddcID := d.Get("sddc_id").(string)
unlockFn := srmNodeCreationLockMutex.Lock(sddcID)
srmNodeID := d.Id()
srmNodeDeleteTask, err := siteRecoverySrmNodesClient.Delete(orgID, sddcID, srmNodeID)
unlockFn := srmNodeCreationLockMutex.Lock(sddcID)
if err != nil {
return HandleDeleteError("SRM Node", sddcID, err)
}
Expand Down

0 comments on commit 67c5749

Please sign in to comment.