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

template_section does not update after VM creation #464

Closed
TGM opened this issue Jun 15, 2023 · 2 comments · Fixed by #474
Closed

template_section does not update after VM creation #464

TGM opened this issue Jun 15, 2023 · 2 comments · Fixed by #474

Comments

@TGM
Copy link

TGM commented Jun 15, 2023

Description

template_section does not update after VM creation

Terraform and Provider version

Terraform v1.3.6
Provider v1.2.2
OpenNebula v6.4.0.1

Affected resources and data sources

template_section

Terraform configuration

template_section {
    name = "RAW"
    elements = {
      data = "<memtune><hard_limit unit='MB'>${var.memory * 1024}</hard_limit></memtune>"
      type = "kvm"
    }
  }

  template_section {
    name = "RAW"
    elements = {
      data = "<memtune><hard_limit unit='MB'>${var.memory * 1024 * 2}</hard_limit></memtune>"
      type = "kvm"
    }
  }

Expected behavior

  + template_section {
      + elements = {
          + "data" = "<memtune><hard_limit unit='MB'>2048</hard_limit></memtune>"
          + "type" = "kvm"
        }
      + name     = "RAW"
    }

Actual behavior

template_section {
name = "RAW"
elements = {
data = "<hard_limit unit='MB'>${var.memory * 1024 * 2}</hard_limit>"
type = "kvm"
}
}

Steps to Reproduce

  1. Create a new VM and declare the template section.
  2. Update the template_section with extra data and run apply

Debug output

No response

Panic output

No response

Important factoids

No response

References

No response

@treywelsh
Copy link
Collaborator

treywelsh commented Jul 5, 2023

Thanks for reporting this

I'm able to reproduce a problem.
It seems I'm able to reproduce a problem with template_section.

I added this to the VM description:

  template_section {
    name= "RAW"
    elements = {
      "data" = "<memtune><hard_limit unit='MB'>256</hard_limit></memtune>"
      "type" = "kvm"
    }
  }

At creation the section RAW is applied, but then the provider is not able to read this section (so it see it as not applied) and the provider shows a diff.

In fact template_section works depending on the name you define. If it's an OpenNebula specific key (like RAW), OpenNebula will add the section in the TEMPLATE. If it's a custom key that OpenNebula doesn't know, it will add the section to the USER_TEMPLATE section of the VM.

The problem is: the reading code of template_section only read sections from USER_TEMPLATE, and ignore section added in TEMPLATE.

There is several ways to fix this, for instance we could add an issue to add a configurable raw section, I'll provide a PR ASAP

@treywelsh
Copy link
Collaborator

I just realized: for now it's possible to define a RAW section via the opennebula_template ressource then instantiate the template.
It also a little note to myself: there's some existing code if we want to add a raw section to the opennebula_virtual_machine resource

@frousselet frousselet added this to the 1.3.0 milestone Jul 12, 2023
@treywelsh treywelsh mentioned this issue Jul 18, 2023
7 tasks
treywelsh added a commit that referenced this issue Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants