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

Provider does not account for datastore overriding driver #490

Open
benjamb opened this issue Sep 13, 2023 · 1 comment
Open

Provider does not account for datastore overriding driver #490

benjamb opened this issue Sep 13, 2023 · 1 comment

Comments

@benjamb
Copy link

benjamb commented Sep 13, 2023

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

@treywelsh
Copy link
Collaborator

Thanks for reporting this, we'll schedule this in a release and I'll take a look as soon as possible

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

No branches or pull requests

2 participants