Telmate / terraform-provider-proxmox

Terraform provider plugin for proxmox
MIT License
2.09k stars 509 forks source link

Ballooning device is always enabled and cannot be disabled #1045

Closed maksimsamt closed 1 month ago

maksimsamt commented 2 months ago

System details:

Issue was introduced in v2 (https://github.com/Telmate/terraform-provider-proxmox/issues/631) and unfortunately not resolved.

Creating new resources works as expected, VM correctly created with memory balloon enabled (e.g. balloon = 2048). Initial config (memory snippet):

...
resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
...
  memory           = 4096
  balloon          = 2048
...
}
...

Decided to disable ballooning device (e.g. balloon = 0):

...
resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
...
  memory           = 4096
  balloon          = 0
...
}
...

In terraform apply output all looks fine, ballooning device should be disabled (0) and result shows as Apply complete! Resources: 0 added, 1 changed, 0 destroyed.:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # proxmox_vm_qemu.cloud_vm_from_packer_template will be updated in-place
  ~ resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
      ~ balloon                = 2048 -> 0
        id                     = "***/qemu/***"
        name                   = "***"
        tags                   = "***"
        # (66 unchanged attributes hidden)

        # (5 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

proxmox_vm_qemu.cloud_vm_from_packer_template: Modifying... [id=***/qemu/***]
proxmox_vm_qemu.cloud_vm_from_packer_template: Modifications complete after 0s [id=***/qemu/***]
╷
│ Warning: VM needs to be rebooted and automatic_reboot is disabled
│ 
│   with proxmox_vm_qemu.cloud_vm_from_packer_template,
│   on main.tf line 42, in resource "proxmox_vm_qemu" "cloud_vm_from_packer_template":
│   42: resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
│ 
│ One or more parameters are modified that only take effect after a reboot (shutdown & start).
╵

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

But as a result, after VM shutdown & start ballooning device still enabled in the PVE virtual machine:

image

When I try to run terraform apply again, it tries to disable device again and again with no success.

Meanwhile ballooning device can only be removed through the Proxmox GUI.

Tinyblargon commented 2 months ago

This is definitely an SDK issue.

maksimsamt commented 2 months ago

This is definitely an SDK issue.

@Tinyblargon, please translate this :) How can be solved this issue?

Tinyblargon commented 2 months ago

@maksimsamt The Terraform project doesn't directly communicate with the PVE API. It uses the Proxmox-SDK then the SDK connects to PVE. The SDK takes care of all the weird quirks of the PVE API. So, the Terraform project only has the simple code.

So data gets transformed twice: Terraform -> SDK -> PVE

Please tell me if something is still unclear.

maksimsamt commented 2 months ago

@maksimsamt The Terraform project doesn't directly communicate with the PVE API. It uses the Proxmox-SDK then the SDK connects to PVE. The SDK takes care of all the weird quirks of the PVE API. So, the Terraform project only has the simple code.

So data gets transformed twice: Terraform -> SDK -> PVE

Please tell me if something is still unclear.

@Tinyblargon , Thank you very much for your clear explanation, now there are no questions at this point.

Just a question, will you address this issue to the corresponding SDK project yourself?

Tinyblargon commented 2 months ago

@maksimsamt I'm also the maintainer of the SDK project, yes. So, at some point I will.

maksimsamt commented 2 months ago

@Tinyblargon,

Most likely this is a directly related problem. Noticed that creating VM from scratch with disabled ballooning device (e.g. balloon = 0), provider ignores this and enable ballooning device:

...
resource "proxmox_vm_qemu" "cloud_vm_from_packer_template" {
...
  memory           = 4096
  balloon          = 0
...
}
...

image

That is, ballooning device always by default is enabled and ignores balloon = 0.