Skip to content

fix(vm): preserve disk deletions in update request#2614

Merged
bpg-dev merged 1 commit intomainfrom
fix/2596-disks-do-not-get-removed-by-terraform
Feb 18, 2026
Merged

fix(vm): preserve disk deletions in update request#2614
bpg-dev merged 1 commit intomainfrom
fix/2596-disks-do-not-get-removed-by-terraform

Conversation

@bpg-dev
Copy link
Copy Markdown
Member

@bpg-dev bpg-dev commented Feb 18, 2026

What does this PR do?

Fixes a bug where removing a secondary disk from a VM configuration would not actually delete the disk in Proxmox. In vmUpdate(), disk interface names (e.g. scsi1) were correctly appended to updateBody.Delete early in the function, but a later assignment updateBody.Delete = del overwrote them with only non-disk deletions. The Proxmox API never received delete=scsi1, so the disk remained.

The fix changes the assignment to append(updateBody.Delete, del...) to merge both disk and non-disk deletions.

Contributor's Note

  • I have run make lint and fixed any issues.
  • I have updated documentation (FWK: schema descriptions + make docs; SDK: manual /docs/ edits).
  • I have added / updated acceptance tests (required for new resources and bug fixes — see ADR-006).
  • I have considered backward compatibility (no breaking schema changes without ! in PR title).
  • For new resources: I followed the reference examples.
  • I have run make example to verify the change works (mainly for SDK / provider config changes).

Proof of Work

Acceptance test:

$ ./testacc TestAccResourceVMDiskRemoval -- -v

=== RUN   TestAccResourceVMDiskRemoval
--- PASS: TestAccResourceVMDiskRemoval (6.43s)
PASS
ok  	github.com/bpg/terraform-provider-proxmox/fwprovider/test	7.108s

The test creates a VM with two disks (scsi0 + scsi1), removes scsi1, then verifies via the Proxmox API that scsi1 no longer exists in the VM configuration.

Mitmproxy verificationdelete: scsi1 is sent in the PUT request:

PUT https://....:8006/api2/json/nodes/pve/qemu/100/config

    delete: scsi1
    name: test-disk-removal
    scsi0:
      file=local-lvm:vm-100-disk-0,...

 << 200 OK

Existing tests still pass:

$ ./testacc TestAccResourceVMDiskRemovalReuseIssue2218

ok  	github.com/bpg/terraform-provider-proxmox/fwprovider/test	9.383s

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #2596

Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @bpg-dev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the Proxmox Terraform provider that prevented the successful deletion of secondary disks from virtual machine configurations. Previously, deletion requests for disks were inadvertently discarded during the update process, leading to discrepancies between the Terraform state and the actual Proxmox environment. The implemented fix ensures that all specified deletions, including those for disks, are correctly processed and sent to the Proxmox API, thereby maintaining data integrity and expected behavior. A new acceptance test has been added to prevent regressions and confirm the fix.

Highlights

  • Bug Fix: Resolved an issue where secondary disk deletions from VM configurations were not correctly applied in Proxmox.
  • Root Cause Identified: The bug was caused by disk deletion requests being inadvertently overwritten by non-disk deletions in the vmUpdate() function.
  • Solution Implemented: Modified the vmUpdate() function to use append for merging all deletion requests, ensuring disk deletions are preserved and sent to the Proxmox API.
  • New Acceptance Test: Introduced a new acceptance test (TestAccResourceVMDiskRemoval) to specifically validate the correct removal of secondary disks and prevent regressions.
Changelog
  • fwprovider/test/resource_vm_disks_test.go
    • Added context, fmt, strconv, and terraform imports.
    • Introduced TestAccResourceVMDiskRemoval to verify the proper deletion of secondary VM disks in Proxmox.
  • proxmoxtf/resource/vm/vm.go
    • Modified the vmUpdate function to use append(updateBody.Delete, del...) instead of updateBody.Delete = del, ensuring that disk deletion requests are merged with other deletions and not overwritten.
Activity
  • The author ran make lint and fixed any issues.
  • New acceptance tests were added to cover the bug fix.
  • Backward compatibility was considered.
  • Proof of work was provided, including acceptance test output and Mitmproxy verification showing the delete: scsi1 parameter being sent.
  • Existing tests were confirmed to still pass.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request provides a solid fix for a critical bug where disk deletions were not being propagated to Proxmox during an update. The change from overwriting the Delete slice to appending to it correctly resolves the issue, and the addition of the TestAccResourceVMDiskRemoval acceptance test ensures robustness and prevents future regressions. The implementation is clean and well-documented, and no security vulnerabilities were found.

@bpg-dev bpg-dev merged commit b12111f into main Feb 18, 2026
6 checks passed
@bpg-dev bpg-dev deleted the fix/2596-disks-do-not-get-removed-by-terraform branch February 18, 2026 05:09
@sebiklamar
Copy link
Copy Markdown

That was very quick, thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disks do not get removed by terraform

2 participants