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

Introduce opennebula_virtual_machine_disk_attachment to prevent issues when replacing image #525

Open
frousselet opened this issue Jan 24, 2024 · 1 comment

Comments

@frousselet
Copy link
Collaborator

frousselet commented Jan 24, 2024

Description

The issue:

Currently, an image is attached to a VM via an attribute (disk).

It's fine until we need to replace the image (for example in order to upgrade the the OS).
In this case, the provider is not able to detach the disk by itself since a disk is an attribute.

A solution:

To fix this, a disk attachment should be an attribute:

Let's imagine a new resource called opennebula_virtual_machine_disk_attachment. It as (at least) 2 attributes: the image ID and the VM id. If one of both attributes changes, the disk attachment is forced recreated.

That means, if I change the image, its ID changes, so the attachement is recreated.

Another way would be to destroy-recreate the entire VM (but I'm quite sure this is not what we want here... 🤷🏻‍♂️).

New or affected resources and data sources

opennebula_virtual_machine (r+d): Deprecate disk attribute
OpenNebula_virtual_machine_disk_attachment (r+d)

Potential terraform configuration

resource "opennebula_image" "my" {

  # ...

  clone_from_image = data.opennebula_image.ubuntu.id

  # ...

}

resource "opennebula_virtual_machine" "my" {

  # ...


  # Deprecated
  # disk {
  #   image_id = opennebula_image.my.id
  #   target   = "vda"
  # }

  # ...

}

resource "opennebula_virtual_machine_disk_attachment" "my" {
  vm_id = opennebula_virtual_machine.my.id
  image_id = opennebula_image.my.id
  target = "vda"
  # and same attributes as the old disk attribute
}

References

No response

@treywelsh
Copy link
Collaborator

Similar to older work (not merged):
issue: #318
PR: #323

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