GithubHelp home page GithubHelp logo

Comments (3)

jaypif avatar jaypif commented on August 25, 2024 1

Hi @baverman

Can you confirm disk are already present in your template ?
I think this is beacuse your disk is already in the template. As it is not explicitly declare in the VM when you apply a second time, the provider consider the VM has no disk and it detach all disks.

If this is the case, it means there is also the same issue with NIC.

For readability and maintenability it is better to have disk explicitely declare in the VM instead of template. However the current behavior is a bug and the provider must be fixed to not remove elements (disks, nic) from a VM in that case.

from terraform-provider-opennebula.

baverman avatar baverman commented on August 25, 2024

Can you confirm disk are already present in your template ?

Yes. Template is defined with a disk.

For readability and maintenability it is better to have disk explicitely declare in the VM instead of template.

I will be glad to use disk image but our current setup assumes some context boot hda device and I did not managed to create a working VM without a template.

from terraform-provider-opennebula.

treywelsh avatar treywelsh commented on August 25, 2024

Thank you for reporting this,

This is not a behavior specific to disks and NICs, unexpected things could happen later for other VM parts (OS, graphics etc...) added via the template only and with an update behavior.

You're in the only case that trigger the problem:
At VM creation, with a template_id, the parts described in the tf file will overwrite template parts. (putting disk in tf file will overwrite disk descriptions from the template. The only part that has a custom behavior is the context part).

This problem is triggered by the diff that terraform see on disk attribute.
In the VM schema, disk type is TypeList, but when reading VM description there is no distinction made between a disk added via the template, and those added via the tf file.

To avoid this diff my first idea was to try to customize the diff via CustomizeDiffFunc, however terraform diff tooling doesn't seems to be enough accurate to remove partial diff.
This seems too complex/inaccurate to implement for now. (As a side note, we aren't up to date in this provider, we don't use the last terraform SDK versions)

Another way to do, is to modify the VM schema and read step to differentiate how we process the disk added via the template, and the disk added via the TF file.
Here is my draft PR, I made some manual tests and it seems to work, feel free to test it and drop comments about it: #100
In brief, disk and NIC added via the template are added in a separated list filled at VM creation.
However it's not possible anymore to detach them later.

It's important to note that this last solution add a bit more of complexity to the VM resource implementation around disk and NIC, which is already complex.
The whole complexity is due to the fact that they are list of schemas and it's not so easy to work with.
So, an other solution that I have to mention (already mentioned here) is:
Instead of having a complex VM resource with all stuffs included and with complex update behaviors, we could introduce opennebula_virtual_machine_nic and opennebula_virtual_machine_disk resources.
This would split VM schema and related code among several resources which would be more simple.
Disks and NIC provided via the template could be immutable, in the same way that I considered above so I'm not sure that we would loose something with this last approach.
Here is an old draft branch that externalize NIC ressource attachment
The problem is that this would break a bit the current provider architecture

from terraform-provider-opennebula.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.