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

feat(vm): deprecate enabled attribute on cdrom/disk devices #1746

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bpg
Copy link
Owner

@bpg bpg commented Feb 6, 2025

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.

Having the enabled attribute on a disk/CD-ROM is quite confusing since it doesn’t map to any device property in PVE. There’s no concept of “enabling” a block device in PVE -- a device either exists or it doesn’t (while there’s a concept of "unattached" disks, that's out of scope for this feature).

When we set enabled = false in the configuration, it effectively means omitting (or removing) the block device from the VM. This makes it tricky to map the remote VM state (in PVE) to the local state in Terraform. In PVE, the absence of a device could mean either the device isn’t defined in the config at all or it’s defined but marked as disabled, which creates ambiguity.

Instead of jumping through hoops to handle this across various use cases (create, update, clone, update clone, etc.), I’ve decided to remove this attribute altogether, as I don’t see a strong practical benefit to keeping it in the config.

Proof of Work

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

Relates #1672

@bpg bpg force-pushed the deprecate-disk-enabled branch from dde83da to f3a38af Compare February 6, 2025 05:34
@@ -379,7 +376,8 @@ func (d CustomStorageDevices) Filter(fn func(*CustomStorageDevice) bool) CustomS
// EncodeValues converts a CustomStorageDevices array to multiple URL values.
func (d CustomStorageDevices) EncodeValues(_ string, v *url.Values) error {
for s, d := range d {
if d.Enabled {
// Explicitly skip disks which have FileID set, so it won't be encoded in "Create" or "Update" operations.
if d.FileID == nil || *d.FileID == "" {
Copy link
Owner Author

Choose a reason for hiding this comment

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

This logic is really hard to reason about. I think we should refactor this use case (as I recall, it is about creating a custom disk from a template) and use different data type there.

@@ -202,11 +200,6 @@ func GetDiskDeviceObjects(
fileFormat = dvDiskFileFormat
}

// Explicitly disable the disk, so it won't be encoded in "Create" or "Update" operations.
if fileID != "" {
diskDevice.Enabled = false
Copy link
Owner Author

Choose a reason for hiding this comment

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

yeah, this place... every time i see it i have a question: "wth, why??" 😕

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.

1 participant