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

Expanding disk incorrectly fails after cloning #1747

Open
jbmay opened this issue Feb 6, 2025 · 2 comments
Open

Expanding disk incorrectly fails after cloning #1747

jbmay opened this issue Feb 6, 2025 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@jbmay
Copy link

jbmay commented Feb 6, 2025

Describe the bug
When deploying a VM that clones from a template, the provider throws an error expanding the disk. However the VM is created successfully in proxmox and the disk shows the desired size.

Example configuration in the module for cloning the template and attempting to expand the disk:

clone {
    vm_id        = data.proxmox_virtual_environment_vms.server_template_vms[0].vms[0].vm_id
    datastore_id = var.root_disk_datastore_id
    full         = true
  }

  disk {
    datastore_id = var.root_disk_datastore_id
    interface    = "scsi0"
    iothread     = true
    discard      = "on"
    size         = var.root_disk_size
  }

and the output of terraform|tofu apply.

Error: disk resize fails: error waiting for VM disk resize: All attempts fail:
#1: the server did not include a data object in the response

Expected behavior
The VM is created from the template and the volume is expanded without the provider throwing an error.

Screenshots
The VM does actually get created and scsi0 gets expanded to the size passed in to root_disk_size

Image

Additional context
Add any other context about the problem here.

  • Single or clustered Proxmox: clustered
  • Proxmox version: 7.4-17
  • Provider version (ideally it should be the latest version): 0.70.1
  • Terraform/OpenTofu version: tofu v1.9.0
  • OS (where you run Terraform/OpenTofu from): Ubuntu 22.04

Debug logs (TF_LOG=DEBUG terraform apply):

2025-02-06T16:54:37.362Z [ERROR] provider.terraform-provider-proxmox_v0.70.1: Response contains error diagnostic: diagnostic_detail="" tf_proto_version=6.8 tf_provider_addr=registry.terraform.io/bpg/proxmox diagnostic_severity=ERROR
  diagnostic_summary=
  | disk resize fails: error waiting for VM disk resize: All attempts fail:
  | #1: the server did not include a data object in the response
   tf_req_id=81b77ccf-b994-81d0-3780-d43def810421 tf_resource_type=proxmox_virtual_environment_vm tf_rpc=ApplyResourceChange @caller=/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov6/internal/diag/diagnostics.go:58 @module=sdk.proto timestamp=2025-02-06T16:54:37.362Z
2025-02-06T16:54:37.363Z [DEBUG] State storage *remote.State declined to persist a state snapshot
2025-02-06T16:54:37.363Z [ERROR] vertex "module.example.proxmox_virtual_environment_vm.example_vm[0]" error: disk resize fails: error waiting for VM disk resize: All attempts fail:
#1: the server did not include a data object in the response
│ Error: disk resize fails: error waiting for VM disk resize: All attempts fail:
│ #1: the server did not include a data object in the response
│ 
│   with module.example.proxmox_virtual_environment_vm.example_vm[0],
│   on ../../modules/example/main.tf line 152, in resource "proxmox_virtual_environment_vm" "example_vm":
│  152: resource "proxmox_virtual_environment_vm" "example_vm" {
│ 
╵
2025-02-06T16:54:37.862Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-02-06T16:54:37.863Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.opentofu.org/bpg/proxmox/0.70.1/linux_amd64/terraform-provider-proxmox_v0.70.1 pid=513271
2025-02-06T16:54:37.863Z [DEBUG] provider: plugin exited
@jbmay
Copy link
Author

jbmay commented Feb 7, 2025

Follow up if it helps troubleshooting:

Discovered that the bug related to expanding disks can be worked around by manually rebooting VMs after applying with updated disk size, followed by a second apply.

Steps:

  • Deploy from template using the template disk size for the initial deploy to ensure you get a clean deploy and state
  • After VMs come up and whatever runs on them initializes, update disk size to new larger size
  • Run tofu apply
    • You will receive the error from tofu saying error waiting for VM disk resize: All attempts fail: for each disk attempting to resize
    • If you check the proxmox UI you will see pending changes on the VMs showing the current disk size already being the updated size and the pending size being the original
    • Manually shutdown and restart the VMs
    • At this point proxmox will show the old size in the GUI still, but the disks in the VM should be the new updated size
  • Run another tofu apply
    • You will see the same error as before, but now if you look in the GUI all the VMs should show the updated size
  • Subsequent applies should show no resources needing to be updated which indicates the tofu state matches the deployed infrastructure

This might even work for the initial VM creation, but I am uncertain if the tofu error is hit before it finishes setting everything else up for the VMs.

@bpg
Copy link
Owner

bpg commented Feb 7, 2025

Hi @jbmay 👋🏼

This issue happens because you're running older PVE 7.4.

The provider uses the newer 8.x API for disk resizing during cloning, which isn’t available in PVE 7.x and results in an unexpected response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
Status: 📥 Inbox
Development

No branches or pull requests

2 participants