Locking on the NSG ID
This commit is contained in:
parent
b93e6e3af7
commit
3ecb0f4fc4
|
@ -172,6 +172,14 @@ func resourceArmNetworkInterfaceCreate(d *schema.ResourceData, meta interface{})
|
||||||
properties.NetworkSecurityGroup = &network.SecurityGroup{
|
properties.NetworkSecurityGroup = &network.SecurityGroup{
|
||||||
ID: &nsgId,
|
ID: &nsgId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkSecurityGroupName, err := parseNetworkSecurityGroupName(nsgId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
armMutexKV.Lock(networkSecurityGroupName)
|
||||||
|
defer armMutexKV.Unlock(networkSecurityGroupName)
|
||||||
}
|
}
|
||||||
|
|
||||||
dns, hasDns := d.GetOk("dns_servers")
|
dns, hasDns := d.GetOk("dns_servers")
|
||||||
|
@ -308,6 +316,17 @@ func resourceArmNetworkInterfaceDelete(d *schema.ResourceData, meta interface{})
|
||||||
resGroup := id.ResourceGroup
|
resGroup := id.ResourceGroup
|
||||||
name := id.Path["networkInterfaces"]
|
name := id.Path["networkInterfaces"]
|
||||||
|
|
||||||
|
if v, ok := d.GetOk("network_security_group_id"); ok {
|
||||||
|
networkSecurityGroupId := v.(string)
|
||||||
|
networkSecurityGroupName, err := parseNetworkSecurityGroupName(networkSecurityGroupId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
armMutexKV.Lock(networkSecurityGroupName)
|
||||||
|
defer armMutexKV.Unlock(networkSecurityGroupName)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = ifaceClient.Delete(resGroup, name, make(chan struct{}))
|
_, err = ifaceClient.Delete(resGroup, name, make(chan struct{}))
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -89,6 +89,14 @@ func resourceArmSubnetCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
properties.NetworkSecurityGroup = &network.SecurityGroup{
|
properties.NetworkSecurityGroup = &network.SecurityGroup{
|
||||||
ID: &nsgId,
|
ID: &nsgId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkSecurityGroupName, err := parseNetworkSecurityGroupName(nsgId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
armMutexKV.Lock(networkSecurityGroupName)
|
||||||
|
defer armMutexKV.Unlock(networkSecurityGroupName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("route_table_id"); ok {
|
if v, ok := d.GetOk("route_table_id"); ok {
|
||||||
|
@ -182,6 +190,17 @@ func resourceArmSubnetDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
name := id.Path["subnets"]
|
name := id.Path["subnets"]
|
||||||
vnetName := id.Path["virtualNetworks"]
|
vnetName := id.Path["virtualNetworks"]
|
||||||
|
|
||||||
|
if v, ok := d.GetOk("network_security_group_id"); ok {
|
||||||
|
networkSecurityGroupId := v.(string)
|
||||||
|
networkSecurityGroupName, err := parseNetworkSecurityGroupName(networkSecurityGroupId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
armMutexKV.Lock(networkSecurityGroupName)
|
||||||
|
defer armMutexKV.Unlock(networkSecurityGroupName)
|
||||||
|
}
|
||||||
|
|
||||||
armMutexKV.Lock(vnetName)
|
armMutexKV.Lock(vnetName)
|
||||||
defer armMutexKV.Unlock(vnetName)
|
defer armMutexKV.Unlock(vnetName)
|
||||||
|
|
||||||
|
|
|
@ -269,15 +269,6 @@ func resourceAzureSubnetHash(v interface{}) int {
|
||||||
return hashcode.String(subnet)
|
return hashcode.String(subnet)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseNetworkSecurityGroupName(networkSecurityGroupId string) (string, error) {
|
|
||||||
id, err := parseAzureResourceID(networkSecurityGroupId)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("[ERROR] Unable to Parse Network Security Group ID '%s': %+v", networkSecurityGroupId, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return id.Path["networkSecurityGroups"], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func expandAzureRmVirtualNetworkVirtualNetworkSecurityGroupNames(d *schema.ResourceData) ([]string, error) {
|
func expandAzureRmVirtualNetworkVirtualNetworkSecurityGroupNames(d *schema.ResourceData) ([]string, error) {
|
||||||
nsgNames := make([]string, 0)
|
nsgNames := make([]string, 0)
|
||||||
|
|
||||||
|
|
|
@ -95,3 +95,12 @@ func parseAzureResourceID(id string) (*ResourceID, error) {
|
||||||
|
|
||||||
return idObj, nil
|
return idObj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseNetworkSecurityGroupName(networkSecurityGroupId string) (string, error) {
|
||||||
|
id, err := parseAzureResourceID(networkSecurityGroupId)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("[ERROR] Unable to Parse Network Security Group ID '%s': %+v", networkSecurityGroupId, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return id.Path["networkSecurityGroups"], nil
|
||||||
|
}
|
Loading…
Reference in New Issue