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

Bug: Idempotency Issue with Disk Block #1100

Closed
trfore opened this issue Sep 7, 2024 · 3 comments
Closed

Bug: Idempotency Issue with Disk Block #1100

trfore opened this issue Sep 7, 2024 · 3 comments
Labels

Comments

@trfore
Copy link

trfore commented Sep 7, 2024

I am running into a idempotency issue whenever an ide drive is added, Terraform will attempt to reshuffle all attached disk on all subsequent calls to terraform <plan/apply>.

  • So for a baseline, if you add two scsi disks testing for idempotency will pass.
  • Once you add an ide drive (cdrom or cloudinit), the shuffling will occur.
  • If you only have two ide drives (cdrom), the shuffling does not occur, however, the issue described in New Disk feature block issue #1090 occurs.

This is problematic when you want to add a cloud-init drive to VMs and occurs in the 3.0.1-rc4 release, master and newdisk branches.

Code Example

terraform {
  required_providers {
    proxmox = {
      source  = "Telmate/proxmox"
      version = "3.0.1-rc4"
    }
  }
}

provider "proxmox" {
  pm_api_url          = "REDACTED"
  pm_api_token_id     = "REDACTED"
  pm_api_token_secret = "REDACTED"
}

resource "proxmox_vm_qemu" "vm" {
  target_node = "pve"
  vmid        = "100"
  vm_state    = "stopped"

  disk {
    type    = "disk"
    slot    = "scsi0"
    storage = "local-lvm"
    size    = "8G"
  }

  disk {
    backup  = false
    type    = "cloudinit"
    slot    = "ide2"
    storage = "local-lvm"
  }
}

Terraform Output

Log output after initial apply:

Terraform will perform the following actions:

  # proxmox_vm_qemu.vm will be updated in-place
  ~ resource "proxmox_vm_qemu" "vm" {
        id                     = "pve/qemu/100"
        # (32 unchanged attributes hidden)

      ~ disk {
          ~ backup               = false -> true
          + format               = "raw"
            id                   = 0
          + size                 = "8G"
          ~ slot                 = "ide2" -> "scsi0"
          ~ type                 = "cloudinit" -> "disk"
            # (18 unchanged attributes hidden)
        }
      ~ disk {
          ~ backup               = true -> false
            id                   = 0
          ~ slot                 = "scsi0" -> "ide2"
          ~ type                 = "disk" -> "cloudinit"
            # (20 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
@Tinyblargon
Copy link
Collaborator

Tinyblargon commented Sep 7, 2024

@trfore the shuffling in the Terraform state is due to the complexity of the disk block. Putting the disks in by id in alphanumeric irder seems to mostly fix this. This is due to a limitation in Terraform, and partially the reason why the disks block was introduced.

As far as I'm aware, the old disk block had this same problem but would actually mutate the vm.

FYI, we currently use the ordered list type for disk. I've tried many times to get the unordered list working. The ordered list allows us to somewhat mitigate this with the alphanumeric id ordering, whereas the unordered list makes it completely random.

If someone knows a terraform provider that handles these big objects in an unordered list please point me to it.

Copy link

github-actions bot commented Nov 7, 2024

This issue is stale because it has been open for 60 days with no activity. Please update the provider to the latest version and, in the issue persist, provide full configuration and debug logs

@github-actions github-actions bot added the stale label Nov 7, 2024
Copy link

This issue was closed because it has been inactive for 5 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants