From 67c574928c82e6b87870abed5c9f2c8153575e57 Mon Sep 17 00:00:00 2001 From: Vasil Atanasov Date: Thu, 17 Aug 2023 15:29:47 +0300 Subject: [PATCH] Changing the lock position in resourceSrmNodeDelete 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 --- vmc/resource_vmc_srm_node.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmc/resource_vmc_srm_node.go b/vmc/resource_vmc_srm_node.go index 51f1ea2..e067f2c 100644 --- a/vmc/resource_vmc_srm_node.go +++ b/vmc/resource_vmc_srm_node.go @@ -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) }