Skip to content

Conversation

@shamilovstas
Copy link
Contributor

Contributor's Note

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated acceptance tests in /fwprovider/tests for any new or updated resources / data sources.
  • I have ran make example to verify that the change works as expected.

Description

This is a WIP pull request to add a pool_membership resource. This resource will allow to add VMs, CTs and storages to resource pools.

Example

resource "proxmox_virtual_environment_vm" "test_vm1" {
  vm_id     = 1234
  node_name = "pve"
  started   = false
}

resource "proxmox_virtual_environment_pool" "test_pool" {
  pool_id = "test-pool"
}

resource "proxmox_virtual_environment_pool_membership" "vm_membership" {
  pool_id = proxmox_virtual_environment_pool.test_pool.id
  vm_id   = proxmox_virtual_environment_vm.test_vm1.id
}

resource "proxmox_virtual_environment_pool_membership" "storage_membership" {
  pool_id    = proxmox_virtual_environment_pool.test_pool.id
  storage_id = "local-lvm"
}

Currently, proxmox_virtual_environment_vm and proxmox_virtual_environment_container use pool_id attribute to add itself to a resource pool. Adding this resource will solve the following issues:

  • It is necessary to support the pool_id in both resources. The level of support is different (proxmox_virtual_environment_vm supports it better than proxmox_virtual_environment_container)
  • Currently the pool_id attribute of proxmox_virtual_environment_container forces replacement, which makes it quite inconvenient to use.
  • Unless there will be a some sort of "utils" package of some sort, supporting pool_id will require duplicated code in proxmox_virtual_environment_container and proxmox_virtual_environment_vm, as the Proxmox Pool API treats CTs and VMS the same iwhen adding them to a pool.
  • Currently there is no way to add a storage to a pool (correct me if I'm wrong here)

Next steps

If this pull request is merged, I suggest these following steps:

  • Remove or mark as deprecated the pool_id attribute in proxmox_virtual_environment_container and proxmox_virtual_environment_vm
  • Remove members field from proxmox_virtual_environment_pool resource as it's currently read only. If the full list of members are required, IMO it's better to use the corresponding datasource

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 #693

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shamilovstas, 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 introduces a new pool_membership resource for the Proxmox Terraform provider. The primary goal is to provide a more robust and centralized way to manage which virtual machines, containers, and storage entities belong to specific resource pools. This change aims to streamline pool management, resolve current limitations and inconsistencies in how pool memberships are handled by existing resources, and expand functionality to include storage membership.

Highlights

  • New Resource: proxmox_virtual_environment_pool_membership: Introduces a dedicated resource to manage the membership of VMs, containers, and storages within Proxmox resource pools.
  • Improved Pool Management: This new resource addresses existing issues with the pool_id attribute in proxmox_virtual_environment_vm and proxmox_virtual_environment_container resources, such as inconsistent support and forced replacements. It also enables adding storages to pools, which was previously not possible.
  • Future Enhancements: The author suggests deprecating the pool_id attribute in proxmox_virtual_environment_container and proxmox_virtual_environment_vm, and removing the read-only members field from proxmox_virtual_environment_pool in subsequent changes.
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
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 introduces a new proxmox_virtual_environment_pool_membership resource, which is a great addition for managing resource pool members declaratively. The implementation is well-structured, with clear separation of concerns between the resource logic, the data model, and comprehensive tests (unit and acceptance). The code is clean and follows the provider's patterns.

I've left a few minor suggestions for improvement, mainly concerning naming consistency in Go, a small bug in an error message, and a documentation clarification. Overall, this is a high-quality contribution.

@shamilovstas shamilovstas changed the title WIP: add pool_membership resource feat: add pool_membership resource Oct 29, 2025
@shamilovstas
Copy link
Contributor Author

Possible improvements: make vm_id and storage_id take a list instead of a single id

@bpg bpg added the ⌛ pending author's response Requested additional information from the reporter label Nov 1, 2025
Copy link
Owner

@bpg bpg left a comment

Choose a reason for hiding this comment

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

Thanks for adding this feeature @shamilovstas! ❤️

This is a solid improvement, and I think the next steps you highlighted make sense.

I have a few minor comments, also gemini flagged Id -> ID renaming, which i think also should be applied.

@shamilovstas
Copy link
Contributor Author

Thanks for adding this feeature @shamilovstas! ❤️

This is a solid improvement, and I think the next steps you highlighted make sense.

I have a few minor comments, also gemini flagged Id -> ID renaming, which i think also should be applied.

Id -> ID renaming has already been done

Signed-off-by: Stanislav Shamilov <[email protected]>
Signed-off-by: Stanislav Shamilov <[email protected]>
@bpg bpg changed the title feat: add pool_membership resource feat(pool): add pool_membership resource Nov 1, 2025
Copy link
Owner

@bpg bpg left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@bpg bpg merged commit 95f180b into bpg:main Nov 1, 2025
5 checks passed
@bpg
Copy link
Owner

bpg commented Nov 1, 2025

@all-contributors please add @shamilovstas for code, testing

@allcontributors
Copy link
Contributor

@bpg

I've put up a pull request to add @shamilovstas! 🎉

@bpg bpg removed the ⌛ pending author's response Requested additional information from the reporter label Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to change resource pool for VM / container without re-creating the resource

2 participants