vatesfr / terraform-provider-xenorchestra

Xen Orchestra provider for Terraform
MIT License
150 stars 32 forks source link

Max memory value does not persists between terraform applys #111

Closed dc232 closed 3 years ago

dc232 commented 3 years ago

when making changes to a vm resource and then running the terraform plan/apply command the max memory value does not change from the default an example can be seen below

Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # xenorchestra_vm.base[0] will be updated in-place
  ~ resource "xenorchestra_vm" "base" {
        id               = "3b18e01c-753c-0101-5581-b980b9da6bfd"
      ~ memory_max       = 8589934592 -> 1073733632
        # (9 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # xenorchestra_vm.base[1] will be updated in-place
  ~ resource "xenorchestra_vm" "base" {
        id               = "33199219-3b7a-0ff2-3f44-4c8def1ab9e7"
      ~ memory_max       = 8589934592 -> 1073733632
        # (9 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # xenorchestra_vm.base[2] will be updated in-place
  ~ resource "xenorchestra_vm" "base" {
        id               = "82982a0b-2017-d328-4fc8-df9bff1bf867"
      ~ memory_max       = 8589934592 -> 1073733632
        # (9 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 3 to change, 0 to destroy.

------------------------------------------------------------------------
ddelnano commented 3 years ago

@dc232 is the problem that the memory value is never updated? Or that Terraform is incorrectly determining the current value? The former is expected until #40 is addressed. The latter would be a new bug.

If that is the case apologies for not understanding your question correctly in Discord.

dc232 commented 3 years ago

@ddelnano I suspect the answer is both my reasoning for this is that the max memory value was defined at the initial apply of the terraform file so it should already be set to 1073733632 not 8589934592 even when updating other changes within the terraform file

The initial terraform code for testing can be found below, for the VLAN I believe it needs to be changed to -1 to test if I remember correctly, if testing in default VLAN of 1

provider "xenorchestra" { #auths to the endpoint
  url = var.endpoint
  username = var.username
  password = var.password
}

data "xenorchestra_pool" "pool" {
  name_label = "xcp-ng-oejjmokz"
}

data "xenorchestra_sr" "sr" {
  name_label = "Local storage"
  pool_id    = data.xenorchestra_pool.pool.id
}

data "xenorchestra_template" "template" {
  name_label = "Kubernetes"
}

data "xenorchestra_pif" "pif" {
  device = "eth0"
  vlan = 10
}

resource "xenorchestra_cloud_config" "base" {
  name = "cloudconfig"
  template = <<EOF
#cloud-init
tiemzone: America/New_York
hostname: terraformtest
package_update: true
package_upgrade: true
users:
  - name: test
    gecos: Test User
    groups: sudo
    passwd: test
    sudo: ['ALL=(ALL) NOPASSWD:ALL']

network:
  version: 2
  ethernets:
    eno1:
      dhcp4: no
      addresses: [192.168.10.10/24]
      gateway4: 192.168.10.1
      nameservers:
         addresses: [192.168.10.1]

runcmd:
 - [ ls, -l, / ]
 - [ sh, -xc, "echo $(date) ': hello world!'" ]
 - [ sh, -c, echo "=========hello world'=========" ]
 - ls -l /root
EOF
}

resource "xenorchestra_vm" "base" {
    count = var.instance_count
    memory_max = 1073733632
    cpus  = 2
    cloud_config = xenorchestra_cloud_config.base.template
    name_label = "TerraformVM-${count.index +1}"
    name_description = "Created by Terraform Script"
    template = data.xenorchestra_template.template.id
    network {
        network_id = data.xenorchestra_pif.pif.network
    }

    disk {
      sr_id = data.xenorchestra_sr.sr.id
      name_label = "Terraform_disk_imavo"
      size = 32212254720
    }
}
ddelnano commented 3 years ago

This was fixed in #144 and will be released in v0.19.0 of the provider!