Lock Route Table / Subnets
This commit is contained in:
parent
c33810f5ce
commit
279b00dd12
|
@ -96,6 +96,15 @@ func resourceArmSubnetCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
properties.RouteTable = &network.RouteTable{
|
||||
ID: &rtId,
|
||||
}
|
||||
|
||||
routeTableName, err := parseRouteTableName(rtId)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
armMutexKV.Lock(routeTableName)
|
||||
defer armMutexKV.Unlock(routeTableName)
|
||||
}
|
||||
|
||||
subnet := network.Subnet{
|
||||
|
@ -182,6 +191,18 @@ func resourceArmSubnetDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
name := id.Path["subnets"]
|
||||
vnetName := id.Path["virtualNetworks"]
|
||||
|
||||
if v, ok := d.GetOk("route_table_id"); ok {
|
||||
rtId := v.(string)
|
||||
routeTableName, err := parseRouteTableName(rtId)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
armMutexKV.Lock(routeTableName)
|
||||
defer armMutexKV.Unlock(routeTableName)
|
||||
}
|
||||
|
||||
armMutexKV.Lock(vnetName)
|
||||
defer armMutexKV.Unlock(vnetName)
|
||||
|
||||
|
|
|
@ -95,3 +95,13 @@ func parseAzureResourceID(id string) (*ResourceID, error) {
|
|||
|
||||
return idObj, nil
|
||||
}
|
||||
|
||||
func parseRouteTableName(routeTableId string) (string, error) {
|
||||
id, err := parseAzureResourceID(routeTableId)
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("[ERROR] Unable to parse Route Table ID '%s': %+v", routeTableId, err)
|
||||
}
|
||||
|
||||
return id.Path["routeTables"], nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue