hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.65k forks source link

Azure VM creation with enable_accelerated_networking on Standard_L8s_v3 - inconsistent OverconstrainedAllocationRequest error #23172

Open VolumezTech opened 1 year ago

VolumezTech commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.5.5

AzureRM Provider Version

3.71.0

Affected Resource(s)/Data Source(s)

azurerm_linux_virtual_machine

Terraform Configuration Files

resource "azurerm_public_ip" "this" {
  count = var.num_of_vm

  sku                 = "Standard"
  name                = "${var.vm_type}-publicIP-${count.index}"
  location            = var.resource_group_location
  resource_group_name = var.resource_group_name
  zones               = [var.zones[count.index % length(var.zones)]]
  allocation_method   = "Static"
}

resource "azurerm_network_interface" "this" {
  count = var.num_of_vm

  name                          = "nic-${var.vm_type}-${count.index}"
  location                      = var.resource_group_location
  resource_group_name           = var.resource_group_name
  enable_accelerated_networking = true

  ip_configuration {
    name                          = "pubConfiguration"
    subnet_id                     = var.subnet_id
    private_ip_address_allocation = "Dynamic"
    public_ip_address_id          = azurerm_public_ip.this["${count.index % var.num_of_vm}"].id
  }

  depends_on = [
    azurerm_public_ip.this
  ]
}

resource "azurerm_linux_virtual_machine" "this" {
  count = var.num_of_vm

  name                         = "${var.vm_type}-${count.index}"
  resource_group_name          = var.resource_group_name
  location                     = var.resource_group_location
  size                         = "Standard_L8s_v3"
  proximity_placement_group_id = var.rdma_mode ? null : var.proximity_pg_group_list[count.index % length(var.zones)]
  availability_set_id          = var.rdma_mode ? var.availability_set_id_list[count.index % length(var.zones)] : null
  source_image_id              =  var.source_image_id
  admin_username               = var.ssh_username
  network_interface_ids = [
    element(azurerm_network_interface.this.*.id, count.index),
  ]

  admin_ssh_key {
    username   = var.ssh_username
    public_key = var.public_key
  }

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  depends_on = [
    azurerm_public_ip.this,
    azurerm_network_interface.this
  ]
}

Debug Output/Panic Output

PLAN:

module.media-vm.azurerm_network_interface.this[7] will be created
resource "azurerm_network_interface" "this" {
applied_dns_servers = (known after apply)
dns_servers = (known after apply)
enable_accelerated_networking = true
enable_ip_forwarding = false
id = (known after apply)
internal_dns_name_label = (known after apply)
internal_domain_name_suffix = (known after apply)
location = "eastus"
mac_address = (known after apply)
name = (known after apply)
private_ip_address = (known after apply)
private_ip_addresses = (known after apply)
resource_group_name = (known after apply)
virtual_machine_id = (known after apply)
ip_configuration {
gateway_load_balancer_frontend_ip_configuration_id = (known after apply)
name = "pubConfiguration"
primary = (known after apply)
private_ip_address = (known after apply)
private_ip_address_allocation = "Dynamic"
private_ip_address_version = "IPv4"
public_ip_address_id = (known after apply)
subnet_id = (known after apply)
}
}

module.media-vm.azurerm_linux_virtual_machine.this[7] will be created
resource "azurerm_linux_virtual_machine" "this" {
admin_username = "adminuser"
allow_extension_operations = true
bypass_platform_safety_checks_on_user_schedule_enabled = false
computer_name = (known after apply)
disable_password_authentication = true
extensions_time_budget = "PT1H30M"
id = (known after apply)
location = "eastus"
max_bid_price = -1
name = (known after apply)
network_interface_ids = (known after apply)
patch_assessment_mode = "ImageDefault"
patch_mode = "ImageDefault"
platform_fault_domain = -1
priority = "Regular"
private_ip_address = (known after apply)
private_ip_addresses = (known after apply)
provision_vm_agent = true
proximity_placement_group_id = (known after apply)
public_ip_address = (known after apply)
public_ip_addresses = (known after apply)
resource_group_name = (known after apply)
size = "Standard_L8s_v3"
.
.
.

Error: waiting for creation of Linux Virtual Machine: (Name "7684-vm-3meq9-media-4" / Resource Group "7684-vm-3meq9-rg"): Code="OverconstrainedAllocationRequest" Message="Allocation failed. VM(s) with the following constraints cannot be allocated, because the condition is too restrictive. Please remove some constraints and try again. Constraints applied are:\n - Networking Constraints (such as Accelerated Networking or IPv6)\n - VM Size\n"

with module.media-vm.azurerm_linux_virtual_machine.this[4],
on ../../../modules/azure/vm/main.tf line 32, in resource "azurerm_linux_virtual_machine" "this":
32: resource "azurerm_linux_virtual_machine" "this" {

Error: waiting for creation of Linux Virtual Machine: (Name "7684-vm-3meq9-media-6" / Resource Group "7684-vm-3meq9-rg"): Code="OverconstrainedAllocationRequest" Message="Allocation failed. VM(s) with the following constraints cannot be allocated, because the condition is too restrictive. Please remove some constraints and try again. Constraints applied are:\n - Networking Constraints (such as Accelerated Networking or IPv6)\n - VM Size\n"

with module.media-vm.azurerm_linux_virtual_machine.this[6],
on ../../../modules/azure/vm/main.tf line 32, in resource "azurerm_linux_virtual_machine" "this":
32: resource "azurerm_linux_virtual_machine" "this" {

Expected Behaviour

Standard_L8s_v3 supports enable_accelerated_networking - I expect successful creation

Actual Behaviour

Inconsistent failures:

Error: waiting for creation of Linux Virtual Machine: (Name "7684-vm-3meq9-media-4" / Resource Group "7684-vm-3meq9-rg"): Code="OverconstrainedAllocationRequest" Message="Allocation failed. VM(s) with the following constraints cannot be allocated, because the condition is too restrictive. Please remove some constraints and try again. Constraints applied are:\n - Networking Constraints (such as Accelerated Networking or IPv6)\n - VM Size\n"

with module.media-vm.azurerm_linux_virtual_machine.this[4], on ../../../modules/azure/vm/main.tf line 32, in resource "azurerm_linux_virtual_machine" "this": 32: resource "azurerm_linux_virtual_machine" "this" {

When I change the VM size to Standard_L8as_v3 - this issue is not recreating

Steps to Reproduce

terraform init terraform apply This issue is inconsistent - sometimes it works

Important Factoids

No response

References

https://github.com/hashicorp/terraform/issues/33794

wenesak commented 1 year ago

same here with preview size : Standard_M48s_1_v3 (VM family Msv3) https://learn.microsoft.com/en-us/azure/virtual-machines/msv3-mdsv3-medium-series