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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with disks upon restore/snapshot revert #2199

Open
4 tasks done
mvandriessen opened this issue May 17, 2024 · 1 comment
Open
4 tasks done

Issue with disks upon restore/snapshot revert #2199

mvandriessen opened this issue May 17, 2024 · 1 comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Milestone

Comments

@mvandriessen
Copy link

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 馃憤 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.8.2

Terraform Provider

v2.7.0

VMware vSphere

v7.0.3

Description

We've created a module for rolling out our VMs and we had used the following logic..

  disk {
    label       = "OS-disk"
    size        = 60
    unit_number = 0
  }
  dynamic "disk" {
    for_each = var.data_disks
    content {
      label       = disk.key
      size        = disk.value.size
      unit_number = index(keys(var.data_disks), disk.key) + 1
    }
  }

This resulted in all our disks after the OS-Disk to be named disk1, disk2, etc - this is the recommended disk naming scheme according to the documentation.

Turns out that when you restore a VM from backup or revert from a snapshot, vSphere defaults to setting the labels like "Hard disk 1" , "Hard disk 2", ... Since label is an immutable attribute, Terraform will destroy the disk and create a new one upon the next plan/apply.

The documentation should be changed to reflect this.

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

  disk {
    label       = "OS-disk"
    size        = 60
    unit_number = 0
  }
  dynamic "disk" {
    for_each = var.data_disks
    content {
      label       = disk.key
      size        = disk.value.size
      unit_number = index(keys(var.data_disks), disk.key) + 1
    }
  }

In our tfvars file, the data_disks block looks like

   data_disks = {
      disk1 = {
        size = 200
      }
    }

Debug Output

https://gist.github.com/mvandriessen/4cdd48205c44ee8dcf05283ede551d67

Panic Output

No response

Expected Behavior

We expect labels to follow the naming convention as outlined in the documentation (disk0, disk1, disk2), in all scenarios.

Actual Behavior

Upon snapshot revert or backup restore, all hard disks receive the label "Hard disk 1", "Hard disk 2", ...

Steps to Reproduce

  • Create a virtual machine
  • Create a vSphere snapshot
  • Revert to snapshot
  • Trigger a plan

Environment Details

No response

Screenshots

No response

References

No response

@mvandriessen mvandriessen added bug Type: Bug needs-triage Status: Issue Needs Triage labels May 17, 2024
Copy link

Hello, mvandriessen! 馃枑

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

@tenthirtyam tenthirtyam added this to the Backlog milestone Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

2 participants