terraform-provider-opennebula
terraform-provider-opennebula copied to clipboard
Provider does not account for datastore overriding driver
Description
As per the datastore docs, setting the DRIVER
attribute will override the DRIVER
set in the image attributes and VM templates.
Setting the driver
parameter for the disk
attribute of a virtual_machine
when the images comes from a datastore that overrides the driver results in the created disk being skipped over by matchDisk()
and excluded from the saved terraform state. Thus the provider will repeatedly attach the same image over and over on subsequent runs of terraform apply
.
Terraform and Provider version
Terraform v1.4.6 on linux_amd64
- provider registry.terraform.io/opennebula/opennebula v1.3.1
Affected resources and data sources
The virtual_machine resource, likely also the template resource.
Terraform configuration
variable "name" {}
variable "image_url" {}
variable "datastore_id" {}
resource "opennebula_image" "image" {
name = var.name
path = var.image_url
datastore_id = var.datastore_id
dev_prefix = "vd"
driver = "qcow2"
}
resource "opennebula_virtual_machine" "vm" {
name = var.name
cpu = "1"
vcpu = "1"
memory = "2048"
os {
arch = "x86_64"
boot = ""
}
disk {
image_id = opennebula_image.image.id
driver = opennebula_image.image.driver
}
}
Expected behavior
The provider should save the disk it created in the terraform state, regardless of whether the driver
matches what is expected.
Actual behavior
The disk is not saved to the terraform state, thus subsequent applies result in new attachments of the same disk.
Steps to Reproduce
Use the provided terraform configuration, run terraform apply
with the datastore_id
set to a datastore that overrides the DRIVER
attribute using raw
, and observe the confused state the provider get in.
Debug output
No response
Panic output
No response
Important factoids
No response
References
No response
Thanks for reporting this, we'll schedule this in a release and I'll take a look as soon as possible