terraform-provider-opennebula
terraform-provider-opennebula copied to clipboard
Disk could be defined as IMAGE in VM template, not only IMAGE_ID
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
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.
Still actual
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
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.
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.