-
-
Notifications
You must be signed in to change notification settings - Fork 261
Description
Description
When cloning a VM that has disks, if the clone configuration does not specify any disk blocks, the inherited disks are not visible in Terraform state. The disk clone test on main explicitly asserts this:
// fully cloned disk, does not have any attributes in state
resource.TestCheckNoResourceAttr("proxmox_virtual_environment_vm.test_disk", "disk.0"),This means users cannot reference inherited disk attributes (e.g. disk.0.path_in_datastore, disk.0.size) on cloned VMs unless they explicitly re-declare the disk blocks.
Expected Behavior
Cloning a VM should carry over inherited disks into Terraform state, matching the basic premise of cloning. If the source VM has disks, the cloned VM state should reflect those disks even when the user doesn't specify disk blocks.
Root Cause
The disk attribute uses Optional + DefaultFunc (not Computed) with a clone guard in disk.Read:
if !isClone || len(currentDiskList) > 0 {
// write disks to state
}This guard was added to prevent Terraform from seeing inherited disks as drift and trying to remove them. However, it hides the disks from state entirely.
Context
This was discovered during the investigation of #2259 (network device removal). The network device fix (PR #2674) used ConfigMode: schema.SchemaConfigModeAttr to solve the equivalent problem for network_device, but that approach doesn't translate directly to disks because:
diskusesDefaultFunc(creates a default 8GB scsi0 disk for non-clone VMs), which conflicts withComputed: truediskhas a complexDiffSuppressFuncandDiffSuppressOnRefresh: true- Changing the schema would affect all VM creation, not just clones
A detailed investigation with possible approaches is tracked in .dev/DISK_CLONE_VISIBILITY_INVESTIGATION.md.
Version
- Provider: 0.98.0
- Terraform: 1.x
- Proxmox VE: 8+