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

nutanix_virtual_machine ignores storage container definition, when used together with image data_source_reference #686

Open
Philbow opened this issue Sep 18, 2024 · 2 comments

Comments

@Philbow
Copy link

Philbow commented Sep 18, 2024

Nutanix Cluster Information

  • Nutanix Cluster (Prism Element / AOS): 6.5.4.5
  • Nutanix Prism Central: pc.2023.4.0.2

Terraform Version

  • Terraform v1.9.5
  • provider registry.terraform.io/nutanix/nutanix v1.9.5

Affected Resource(s)

  • nutanix_virtual_machine

Terraform Configuration Files

resource "nutanix_virtual_machine" "vm" {
  name         = "nutanix_reproducable"
  cluster_uuid = "###ADD_YOUR_VALUE###"

  num_vcpus_per_socket = 2
  num_sockets          = 1
  memory_size_mib      = 2048

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = "<desired_image_uuid>"
    }

    storage_config {
      storage_container_reference {
        kind = "storage_container"
        uuid = "###ADD_YOUR_VALUE###"
      }
    }

    device_properties {
      device_type = "DISK"
      disk_address = {
        device_index = 0
        adapter_type = "SCSI"
      }
    }
    disk_size_mib = 20480
  }

  nic_list {
    subnet_uuid = "###ADD_YOUR_VALUE###"
  }
}

Debug Output

  • First run was successful, indicating that the storage container was correctly chosen (as defined)
    • Looking into the UI, the storage container was ignored from terraform code and another storage container (SelfServiceContainer) was chosen instead
  • After running terraform apply a second time, Terraform indicates changes to the storage container
    • 4c2b9a49-e07c-48b6-bd05-ca985b441f99 > SelfServiceContainer
    • b4206040-5a06-43ed-80a9-88210fb8c2d1 > Initially provided storage container
Terraform will perform the following actions:

  # nutanix_virtual_machine.vm will be updated in-place
  ~ resource "nutanix_virtual_machine" "vm" {
        id                                               = "cec615e1-b5cf-4fb1-a23b-6fcd96bc86f6"
        name                                             = "###ADD_YOUR_VALUE###"
        # (41 unchanged attributes hidden)

      ~ disk_list {
            # (5 unchanged attributes hidden)

          ~ storage_config {
                # (1 unchanged attribute hidden)

              ~ storage_container_reference {
                    name = "SelfServiceContainer"
                  ~ uuid = "4c2b9a49-e07c-48b6-bd05-ca985b441f99" -> "b4206040-5a06-43ed-80a9-88210fb8c2d1"
                    # (2 unchanged attributes hidden)
                }
            }

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

Expected Behavior

When using a data_source_reference with image, Terraform should use the correctly specified storage container in the first run, to omit unsupported changes in the second run.

Actual Behavior

When using a data_source_reference with image, Terraform uses a wrong storage container (SelfServiceContainer) in the first run.

Steps to Reproduce

  1. terraform apply -auto-approve
  2. terraform apply to see unplanned changes or check the storage container in the UI from the first run

Important Factors

  • Use data_source_reference with image and a storage_config with storage_container_reference.
  • When removing the data_source_reference everything is deployed as specified and the correct storage container is chosen.
@pipoe2h
Copy link

pipoe2h commented Sep 18, 2024

@Philbow, by design, you cannot choose a different storage container when creating a VM from an existing image. You can check this by following the steps through the Prism Central interface.

To understand this better, is your intention to add an additional disk to the virtual machine, or to specify where to store the cloned image disk for that VM?

@Philbow
Copy link
Author

Philbow commented Sep 18, 2024

Sure I forgot that the image is only referenced in the VM to reduce storage usage - this makes sense.

A second disk without image reference would use the defined storage container.

An error for mutual exclusivness would be helpful. Please decide if this makes sense or not (and close the ticket if you wish so).

Thanks for the quick response.

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

2 participants