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 could be defined as IMAGE in VM template, not only IMAGE_ID #484

Open
deynekoaa opened this issue Aug 18, 2023 · 5 comments
Open

Disk could be defined as IMAGE in VM template, not only IMAGE_ID #484

deynekoaa opened this issue Aug 18, 2023 · 5 comments

Comments

@deynekoaa
Copy link

Description

Problem: Disk size not changed after creating VMs from first template

Goal:
terraform can not work with VM templates, that have disk info as IMAGE (i.e. name), not as IMAGE_ID (identifier)
First template

DISK = [
  IMAGE = "ubuntu-22.04-amd64.base_image.test_system.stable.b20230812-7.ceph-ssd",
  IMAGE_SIZE = "4096" ]

Output terraform plan:

      + disk                   = [
          + {
              + cache                    = null
              + computed_cache           = (known after apply)
              + computed_dev_prefix      = (known after apply)
              + computed_discard         = (known after apply)
              + computed_driver          = (known after apply)
              + computed_io              = (known after apply)
              + computed_size            = (known after apply)
              + computed_target          = (known after apply)
              + computed_volatile_format = (known after apply)
              + dev_prefix               = null
              + discard                  = null
              + disk_id                  = (known after apply)
              + driver                   = null
              + image_id                 = -1
              + io                       = null
              + size                     = 15360
              + target                   = null
              + volatile_format          = null
              + volatile_type            = null
            },
        ]

Second template:

DISK = [
  IMAGE_ID = "81726",
  IMAGE_SIZE = "4096" ]

Output terraform plan:

      + disk                   = [
          + {
              + cache                    = null
              + computed_cache           = (known after apply)
              + computed_dev_prefix      = (known after apply)
              + computed_discard         = (known after apply)
              + computed_driver          = (known after apply)
              + computed_io              = (known after apply)
              + computed_size            = (known after apply)
              + computed_target          = (known after apply)
              + computed_volatile_format = (known after apply)
              + dev_prefix               = null
              + discard                  = null
              + disk_id                  = (known after apply)
              + driver                   = null
              + image_id                 = 81726
              + io                       = null
              + size                     = 15360
              + target                   = null
              + volatile_format          = null
              + volatile_type            = null
            },
        ]

As result, disk size changed in VM from second template

Terraform and Provider version

# terraform -v
Terraform v1.5.5
on linux_amd64
...
- Installed opennebula/opennebula v1.3.0 (self-signed, key ID A0224DDC2BF90FA7)
...
OpenNebula 5.10.1

Affected resources and data sources

opennebula_virtual_machine

Terraform configuration

terraform {
  required_providers {
    opennebula = {
      source = "OpenNebula/opennebula"
      version = "~> 1.3"
    }
  }
}

locals {
  config  = yamldecode(file("configfile.yaml"))
}

provider "opennebula" {
  endpoint = local.config.one_endpoint
  username = local.config.one_username
  password = local.config.one_password
}

data "opennebula_templates" "one_templates" {
  name_regex = local.config.template_regex
  has_cpu    = true
  sort_on   = "register_date"
  order      = "ASC"
}

resource "opennebula_virtual_machine" "one_vm" {
  name = local.config.vm_name
  description = "terraform"

  template_id = data.opennebula_templates.one_templates.templates[0].id

  disk {
    size = 15360 # 15GB
  }
}

output "one_vm_ip" {
  description = "IP address of the opennebula VM"
  value       = resource.opennebula_virtual_machine.one_vm.ip
}

Expected behavior

Both VMs has 15Gb disk size

Actual behavior

Only VM from second template has 15Gb disk size

Steps to Reproduce

Just try to create VMs from two templates

Debug output

No response

Panic output

No response

Important factoids

No response

References

No response

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity and it has not the 'status: confirmed' label or it is not in a milestone. Remove the 'status: stale' label or comment, or this will be closed in 5 days.

@deynekoaa
Copy link
Author

Still actual

@treywelsh
Copy link
Collaborator

treywelsh commented Oct 6, 2023

Running TF_LOG=TRACE TF_LOG_PATH=terraform.log terraform apply you'll have some more logs, it may help.
There's a chance to see this message in logs: "[INFO] ignore disk without image_id and type"

Digging the provider code and history a to understand:

The problem may be due to this line
The provider check if the image_id is not equal to -1 (a default value)

image_id value to -1 by default was added by PR #75 to solve issue #71, which could be discussed (is it legitimate etc.)

At first glance we could try to add a check on the image attribute, however, I'll need to make a bunch of test to check if it break something else

@treywelsh treywelsh self-assigned this Oct 6, 2023
Copy link

github-actions bot commented Nov 6, 2023

This issue is stale because it has been open for 30 days with no activity and it has not the 'status: confirmed' label or it is not in a milestone. Remove the 'status: stale' label or comment, or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2023
@treywelsh treywelsh reopened this Nov 13, 2023
@treywelsh treywelsh reopened this Nov 13, 2023
Copy link

This issue is stale because it has been open for 30 days with no activity and it has not the 'status: confirmed' label or it is not in a milestone. Remove the 'status: stale' label or comment, or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
@frousselet frousselet reopened this Dec 20, 2023
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

3 participants