Skip to content

Commit

Permalink
azurerm_network_manager_deployment - add parallel locks (#25368)
Browse files Browse the repository at this point in the history
* add parallel locks for deployment with same ID

* add lock in delete/update
  • Loading branch information
teowa authored Mar 26, 2024
1 parent 1976bc7 commit ec308a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/services/network/network_manager_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/networkmanagers"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate"
Expand Down Expand Up @@ -108,6 +109,9 @@ func (r ManagerDeploymentResource) Create() sdk.ResourceFunc {
normalizedLocation := azure.NormalizeLocation(state.Location)
id := parse.NewNetworkManagerDeploymentID(networkManagerId.SubscriptionId, networkManagerId.ResourceGroupName, networkManagerId.NetworkManagerName, normalizedLocation, state.ScopeAccess)

locks.ByID(id.ID())
defer locks.UnlockByID(id.ID())

metadata.Logger.Infof("creating %s", *id)

listParam := networkmanagers.NetworkManagerDeploymentStatusParameter{
Expand Down Expand Up @@ -214,6 +218,9 @@ func (r ManagerDeploymentResource) Update() sdk.ResourceFunc {
return err
}

locks.ByID(id.ID())
defer locks.UnlockByID(id.ID())

metadata.Logger.Infof("updating %s..", *id)
client := metadata.Client.Network.NetworkManagers

Expand Down Expand Up @@ -294,6 +301,9 @@ func (r ManagerDeploymentResource) Delete() sdk.ResourceFunc {
return err
}

locks.ByID(id.ID())
defer locks.UnlockByID(id.ID())

metadata.Logger.Infof("deleting %s..", *id)
input := networkmanagers.NetworkManagerCommit{
ConfigurationIds: &[]string{},
Expand Down

0 comments on commit ec308a9

Please sign in to comment.