Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_virtual_network_dns_servers: move vnet locker before GET virtual network #27036

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func resourceVirtualNetworkDnsServersCreate(d *pluginsdk.ResourceData, meta inte
// This is a virtual resource so the last segment is hardcoded
id := parse.NewVirtualNetworkDnsServersID(vnetId.SubscriptionId, vnetId.ResourceGroupName, vnetId.VirtualNetworkName, "default")

locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName)
defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName)

vnet, err := client.Get(ctx, *vnetId, virtualnetworks.DefaultGetOperationOptions())
if err != nil {
if response.WasNotFound(vnet.HttpResponse) {
Expand All @@ -80,9 +83,6 @@ func resourceVirtualNetworkDnsServersCreate(d *pluginsdk.ResourceData, meta inte
return fmt.Errorf("retrieving %s: %+v", vnetId, err)
}

locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName)
defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName)

if vnet.Model == nil {
return fmt.Errorf("retrieving %s: `model` was nil", vnetId)
}
Expand Down Expand Up @@ -164,6 +164,9 @@ func resourceVirtualNetworkDnsServersUpdate(d *pluginsdk.ResourceData, meta inte
// This is a virtual resource so the last segment is hardcoded
id := parse.NewVirtualNetworkDnsServersID(vnetId.SubscriptionId, vnetId.ResourceGroupName, vnetId.VirtualNetworkName, "default")

locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName)
defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName)

vnet, err := client.Get(ctx, *vnetId, virtualnetworks.DefaultGetOperationOptions())
if err != nil {
if response.WasNotFound(vnet.HttpResponse) {
Expand All @@ -172,9 +175,6 @@ func resourceVirtualNetworkDnsServersUpdate(d *pluginsdk.ResourceData, meta inte
return fmt.Errorf("retrieving %s: %+v", vnetId, err)
}

locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName)
defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName)

if vnet.Model == nil {
return fmt.Errorf("retrieving %s: `model` was nil", vnetId)
}
Expand Down Expand Up @@ -221,6 +221,9 @@ func resourceVirtualNetworkDnsServersDelete(d *pluginsdk.ResourceData, meta inte
return err
}

locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName)
defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName)

vnetId := commonids.NewVirtualNetworkID(id.SubscriptionId, id.ResourceGroup, id.VirtualNetworkName)

vnet, err := client.Get(ctx, vnetId, virtualnetworks.DefaultGetOperationOptions())
Expand All @@ -232,9 +235,6 @@ func resourceVirtualNetworkDnsServersDelete(d *pluginsdk.ResourceData, meta inte
return fmt.Errorf("retrieving %s: %+v", vnetId, err)
}

locks.ByName(id.VirtualNetworkName, VirtualNetworkResourceName)
defer locks.UnlockByName(id.VirtualNetworkName, VirtualNetworkResourceName)

if vnet.Model == nil {
return fmt.Errorf("retrieving %s: `model` was nil", vnetId)
}
Expand Down
Loading