Telmate / terraform-provider-proxmox

Terraform provider plugin for proxmox
MIT License
2.19k stars 530 forks source link

Disk is being detached instead of removing from storage #983

Open erya777 opened 6 months ago

erya777 commented 6 months ago

When removing a disk from terraform its being left in "unused disk" state instead of deleting disk from storage. Using provider version 3.0.1-rc1 and proxmox version 8.1 After running following plan the disk is left detached in "Unused Disk 0" slot. Expected behavior is complete disk removal from storage.

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.server["vm-01"] will be updated in-place
  ~ resource "proxmox_vm_qemu" "server" {
        id                        = "node01/qemu/104"
        name                      = "vm-01"
        # (40 unchanged attributes hidden)

      ~ disks {
          ~ scsi {
              - scsi1 {
                  - disk {
                      - backup               = true -> null
                      - discard              = false -> null
                      - emulatessd           = false -> null
                      - format               = "raw" -> null
                      - id                   = 4 -> null
                      - iops_r_burst         = 0 -> null
                      - iops_r_burst_length  = 0 -> null
                      - iops_r_concurrent    = 0 -> null
                      - iops_wr_burst        = 0 -> null
                      - iops_wr_burst_length = 0 -> null
                      - iops_wr_concurrent   = 0 -> null
                      - iothread             = false -> null
                      - linked_disk_id       = -1 -> null
                      - mbps_r_burst         = 0 -> null
                      - mbps_r_concurrent    = 0 -> null
                      - mbps_wr_burst        = 0 -> null
                      - mbps_wr_concurrent   = 0 -> null
                      - readonly             = false -> null
                      - replicate            = true -> null
                      - size                 = 31 -> null
                      - storage              = "scsi-datastore" -> null
                    }
                }

                # (1 unchanged block hidden)
            }
        }

        # (2 unchanged blocks hidden)
    }
aegrodin commented 6 months ago

Can confirm, had the same issue just recently and had to delete unused disks manually in Web UI.

Tinyblargon commented 6 months ago

Previous implementations of the disk handling would occasionally get confused which disk is which, resulting in all disks getting detached. Since this issue has been fixed in https://github.com/Telmate/proxmox-api-go/pull/255 we can look into adding a feature to permanently delete detached disks.

maksimsamt commented 5 months ago

@Tinyblargon ,

we can look into adding a feature to permanently delete detached disks.

Are you planning to add this feature? Currently, after some disk modifications add/delete/etc, garbage remains in the form of unused/detached disks and therefore cleaning must be done manually, so, would be very useful and helpful to have automated unused disk deletion.

Tinyblargon commented 5 months ago

@maksimsamt eventually yes. As i also maintain the SDK used by this project to connect to proxmox, a lot of my work has been going there. I don't see this feature coming any time soon.