Skip to content

[Bug] No disk resizing in .nutanix_virtual_machine_v2 when using data_source #810

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

Open
nanori opened this issue Apr 3, 2025 · 2 comments

Comments

@nanori
Copy link

nanori commented Apr 3, 2025

Nutanix Cluster Information

Terraform Version

Affected Resource(s)

$ terraform -v
Terraform v1.9.8

  • provider registry.terraform.io/nutanix/nutanix v2.0.0

Terraform Configuration Files

resource "nutanix_virtual_machine_v2" "vm" {
  name                  = var.vm_hostname
  description           = var.vm_hostname
  num_cores_per_socket  = var.vm_num_cpus
  memory_size_bytes     = var.vm_memory
  power_state           = "ON"
  num_sockets           = 1
  cluster {
    ext_id = var.cluster_uuid
  }
  guest_customization {
    config {
      cloud_init {
        cloud_init_script {
          user_data {
            value = var.vm_ignition_file
          }
        }
      }
    }
  }
  
  # Primary disk
  disks {
    disk_address {
      bus_type = "SCSI"
      index = 0
    }
    backing_info {
      vm_disk {
        disk_size_bytes = var.primary_disk_size * pow(1024, 3)
        data_source {
          reference {
            image_reference {
              image_ext_id = data.nutanix_images_v2.rhcos_image.images.0.ext_id
            }
          }
        }
      }
    }
  }

  lifecycle {
    ignore_changes = [
      nics[0].network_info[0].ipv4_config[0].should_assign_ip,
      cd_roms,
      guest_customization,
    ]
  }
}

Debug Output

Panic Output

Expected Behavior

Disk size should be var.primary_disk_size GiB

Actual Behavior

Plan / Apply show disk size to var.primary_disk_size GiB but actual it's the size of cloned image.

When we reapply, the provider throw an error :

Error: error waiting for disk (ZXJnb24=:af5edd7a-c1aa-59b8-9076-dd6710b1bf66) to be updated: error_detail: Failed to perform the operation on the VM with UUID 'dc7b6abd-7d8e-4a2c-7afc-72f4a80a085d' because specifying both 'dataSource' and 'diskSizeBytes' is not allowed.

Manually change disk size by updating the VM in Prism Central works well.

Steps to Reproduce

  1. terraform apply

Important Factors

Similar to an issue on the Ansible collection : nutanix/nutanix.ansible#578

@FlorianLaunay
Copy link

There is no error since v2.1.0 thanks to #761 .
But now this lack of resize occurs silently 😢
As mentioned by @akli-ime the API does not support both arguments.
But can we consider a 2-step operation during the Create Context ?
Firstly a clone with dataSource and then a resize with diskSizeBytes and the dataSource mapping deletion.

@Rapsody09
Copy link

Hi, same problem here, trying to resize disk to 50GB, plan looks ok :

Image

But after apply, on VM disk is not resized and stays to 2.2GB :

Image

And we get no error, this is very confusing.

We are using :
opentofu:1.9.1
nutanix/nutanix v2.2.0

Our configuration is similar to @FlorianLaunay

  # This is the OS disk
  disks {
    disk_address {
      bus_type = "SCSI"
      index    = 0
    }
    backing_info {
      vm_disk {              
        disk_size_bytes = each.value.DISK0 * 1073741824 // Convert GiB to bytes
        data_source {
          reference {
            image_reference {
              image_ext_id = coalesce([for image in data.nutanix_images_v2.os_images.images : image.name == each.value.IMAGE ? image.ext_id : null]...)
            }
          }
        }
      }
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants