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

Disk change in VM Template doesn't take effect #491

Closed
axbgrossi opened this issue Oct 2, 2023 · 2 comments · Fixed by #541
Closed

Disk change in VM Template doesn't take effect #491

axbgrossi opened this issue Oct 2, 2023 · 2 comments · Fixed by #541

Comments

@axbgrossi
Copy link
Contributor

axbgrossi commented Oct 2, 2023

Description

Removing a disk from VM Template in terraform doesn't generate one.template.update in ONe, only a one.template.info request for the diff as there's no if d.HasChange("disk") condition in https://github.com/OpenNebula/terraform-provider-opennebula/blob/master/opennebula/resource_opennebula_template.go#L541C67-L541C67

Terraform and Provider version

Terraform v1.5.1
on darwin_arm64

  • provider registry.terraform.io/opennebula/opennebula v1.3.0

Affected resources and data sources

opennebula_template

Terraform configuration

resource "opennebula_template" "instance-template" {
  name               = var.instance_template_name
  cpu                = var.cpu
  vcpu               = var.vcpu
  memory             = var.memory_gb * 1024
  permissions        = "660"
  sched_requirements = var.cluster_id
  context = {
    AXC_VMTYPE          = "cf"
    DNS                 = var.dns
    DNS_HOSTNAME        = "YES"
    NETWORK             = "YES"
    REPORT_READY        = "YES"
    SEARCH_DOMAIN       = var.search_domain
    START_SCRIPT_BASE64 = var.start_script_base64
    TOKEN               = "YES"
  }
  cpumodel {
    model = "IvyBridge-IBRS"
  }
  disk {
    dev_prefix = "sd"
    discard    = "unmap"
    image_id   = 11
    size       = 20480
  }
  features {
    guest_agent        = "YES"
    virtio_scsi_queues = "3"
  }
  os {
    arch = "x86_64"
    boot = ""
  }
  raw {
    data = "<console/>"
    type = "kvm"
  }
  graphics {
    listen = "0.0.0.0"
    type   = "VNC"
  }
  nic {
    network_id = var.network_id
    security_groups = [
      0,
    ]
  }
}

Expected behavior

only 20G disk should exist, any other disks in this template should be deleted:

  # module.instance-template["cf"].opennebula_template.instance-template will be updated in-place
  ~ resource "opennebula_template" "instance-template" {
        id                 = "70"
        name               = "cf"
        # (13 unchanged attributes hidden)

      - disk {
          - cache           = "writeback" -> null
          - dev_prefix      = "sd" -> null
          - discard         = "unmap" -> null
          - image_id        = -1 -> null
          - size            = 358400 -> null
          - volatile_format = "raw" -> null
          - volatile_type   = "fs" -> null
        }

        # (7 unchanged blocks hidden)
    }

Actual behavior

Apply completes successfully, reporting template change:
image

and Disk deletion does not take effect in ONe interface:
image

Steps to Reproduce

create Template with 2 disks or more, then delete one disk from terraform code and see if it takes effect in ONe console

Debug output

No response

Panic output

No response

Important factoids

No response

References

No response

@treywelsh
Copy link
Collaborator

Same for nic section

@volodaiy
Copy link

volodaiy commented Nov 20, 2023

I confirm, same problem. Provider version 1.3, 1.2.2. Terraform version 1.6.4, 1.5.7

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

Successfully merging a pull request may close this issue.

3 participants