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

Creating VM with multiple disks only creates one disk #242

Open
kjkriegel opened this issue May 3, 2023 · 4 comments
Open

Creating VM with multiple disks only creates one disk #242

kjkriegel opened this issue May 3, 2023 · 4 comments

Comments

@kjkriegel
Copy link

Creating a VM with multiple disks leads to only the second disk being created. Running terraform apply a second time leads to the disk being renamed to the name of the first disk. Running terraform apply a third time finally creates both disk.

Versions:

  • xo-server 5.113.0
  • xo-web 5.116.1
  • XCP-ng 8.2.1

Steps to reproduce:

  1. Apply following terraform file:
provider "xenorchestra" {
 url = "wss://example.com"
}

terraform {
 required_providers {
   xenorchestra = {
     source  = "terra-farm/xenorchestra"
     version = "0.24.1"
   }
 }
}

data "xenorchestra_pool" "pool" {
 name_label = "pool1"
}

data "xenorchestra_template" "fcos" {
 name_label = "FCOS"
}

data "xenorchestra_sr" "local" {
 name_label = "Local storage"
}

data "xenorchestra_network" "guests" {
 name_label = "guests"
}

resource "xenorchestra_vm" "vm" {
   memory_max = 2048 * pow(1024, 2)
   cpus  = 1
   name_label = "disks"
   hvm_boot_firmware = "uefi"
   template = data.xenorchestra_template.fcos.id
   auto_poweron = true

   affinity_host = data.xenorchestra_pool.pool.master

   disk {
     sr_id      = data.xenorchestra_sr.local.id
     name_label = "vm_root"
     size       = 10 * pow(1024, 3)
   }

   disk {
     sr_id      = data.xenorchestra_sr.local.id
     name_label = "vm_var"
     size       = 8 * pow(1024, 3)
   }

   network {
     network_id = data.xenorchestra_network.guests.id
   }
}
@ddelnano
Copy link
Collaborator

ddelnano commented May 8, 2023

Hi @kjkriegel, please provide the logs of the three terraform runs mentioned above (setting the TF_LOG=DEBUG environment variable).

The acceptance tests verify that the provider is able to create a VM with two disks (source) using terraform config very similar to your example. Providing the logs will help to determine why your example is behaving differently than the tests.

@KristoferGrahn
Copy link

Have the same issue, the first apply ignores the disk with the "lowest" name.
So if i define 4 and i get 3 on the host.

The following apply's changes the disk names around randomly.

Total noob on this so home it makes sense,

apply1_debug.log
apply2_debug.log
apply3_debug.log
tdisql10.tf.txt

@ddelnano
Copy link
Collaborator

@KristoferGrahn thanks for the logs and I have a hunch for what is going on now :)

I believe the provider is making assumptions about the type of template in use. Can you provide the output of both of the commands below:

$ xo-cli xo.getAllObjects filter='json:{"type": "VM-template", "name_label": "TdiTemplate"}'

# The template uuid can be found from `xe template-list`
$ xe template-param-list uuid=<template uuid>

Let me know if you have any questions about how to collect that information.

@KristoferGrahn
Copy link

KristoferGrahn commented Mar 13, 2024

@ddelnano Big thanks for taking the time to check my report !

 xo-cli xo.getAllObjects filter='json:{"type": "VM-template", "name_label": "TdiTemplate"}'
{
  "62aaf70c-6ee5-f31d-3f81-adafeaa72dce": {
    "type": "VM-template",
    "addresses": {},
    "auto_poweron": false,
    "bios_strings": {
      "bios-vendor": "Xen",
      "bios-version": "",
      "system-manufacturer": "Xen",
      "system-product-name": "HVM domU",
      "system-version": "",
      "system-serial-number": "",
      "enclosure-asset-tag": "",
      "hp-rombios": "",
      "oem-1": "Xen",
      "oem-2": "MS_VM_CERT/SHA1/bdbeb6e0a816d43fa6d3fe8aaef04c2bad9d3e3d"
    },
    "blockedOperations": {},
    "boot": {
      "order": "ncd",
      "firmware": "bios"
    },
    "CPUs": {
      "max": 1,
      "number": 1
    },
    "current_operations": {},
    "expNestedHvm": false,
    "viridian": false,
    "high_availability": "",
    "memory": {
      "dynamic": [
        536870912,
        536870912
      ],
      "static": [
        268435456,
        536870912
      ],
      "size": 536870912
    },
    "installTime": null,
    "name_description": "Tdi Template for Debian 10",
    "name_label": "TdiTemplate",
    "other": {
      "base_template_name": "Debian Buster 10.0",
      "import_task": "OpaqueRef:4d97169c-8b7e-465f-8785-8100ff249855",
      "mac_seed": "b1cd4665-0870-54ca-528b-fb2559cd302e",
      "install-methods": "cdrom,nfs,http,ftp",
      "linux_template": "true"
    },
    "os_version": {},
    "power_state": "Halted",
    "hasVendorDevice": false,
    "snapshots": [],
    "startDelay": 0,
    "startTime": null,
    "secureBoot": false,
    "tags": [],
    "VIFs": [
      "909b9989-4fff-bfb6-5532-b422b315c222"
    ],
    "VTPMs": [],
    "virtualizationMode": "hvm",
    "$container": "ad63dbfa-b690-197c-c742-5175be301f1d",
    "$VBDs": [
      "ce716461-e6a5-3acc-1c91-7d56e75923a3"
    ],
    "VGPUs": [],
    "$VGPUs": [],
    "vga": "std",
    "videoram": "8",
    "coresPerSocket": 1,
    "isDefaultTemplate": false,
    "template_info": {
      "disks": [],
      "install_methods": [
        "cdrom",
        "nfs",
        "http",
        "ftp"
      ]
    },
    "id": "62aaf70c-6ee5-f31d-3f81-adafeaa72dce",
    "uuid": "62aaf70c-6ee5-f31d-3f81-adafeaa72dce",
    "$pool": "ad63dbfa-b690-197c-c742-5175be301f1d",
    "$poolId": "ad63dbfa-b690-197c-c742-5175be301f1d",
    "_xapiRef": "OpaqueRef:19630a11-f4fc-4f8b-bcb4-d83e107a0313"
  }
}
######
xe template-param-list uuid=62aaf70c-6ee5-f31d-3f81-adafeaa72dce
uuid ( RO)                                  : 62aaf70c-6ee5-f31d-3f81-adafeaa72dce
                            name-label ( RW): TdiTemplate
                      name-description ( RW): Tdi Template for Debian 10
                          user-version ( RW): 1
                         is-a-template ( RW): true
                   is-default-template ( RW): false
                         is-a-snapshot ( RO): false
                           snapshot-of ( RO): <not in database>
                             snapshots ( RO): 
                         snapshot-time ( RO): 19700101T00:00:00Z
                         snapshot-info ( RO): 
                                parent ( RO): <not in database>
                              children ( RO): 
                     is-control-domain ( RO): false
                           power-state ( RO): halted
                         memory-actual ( RO): 0
                         memory-target ( RO): 0
                       memory-overhead ( RO): 7340032
                     memory-static-max ( RW): 536870912
                    memory-dynamic-max ( RW): 536870912
                    memory-dynamic-min ( RW): 536870912
                     memory-static-min ( RW): 268435456
                      suspend-VDI-uuid ( RW): <not in database>
                       suspend-SR-uuid ( RW): <not in database>
                          VCPUs-params (MRW): 
                             VCPUs-max ( RW): 1
                      VCPUs-at-startup ( RW): 1
                actions-after-shutdown ( RW): Destroy
              actions-after-softreboot ( RW): Soft reboot
                  actions-after-reboot ( RW): Restart
                   actions-after-crash ( RW): Restart
                         console-uuids (SRO): 
                                   hvm ( RO): false
                              platform (MRW): timeoffset: 0; cores-per-socket: 1; videoram: 8; hpet: true; secureboot: false; device-model: qemu-upstream-compat; apic: true; device_id: 0001; vga: std; nx: true; pae: true; viridian: false; acpi: 1
                    allowed-operations (SRO): changing_NVRAM; changing_dynamic_range; changing_shadow_memory; changing_static_range; migrate_send; provision; destroy; export; clone; copy
                    current-operations (SRO): 
                    blocked-operations (MRW): 
                   allowed-VBD-devices (SRO): 0; 1; 2; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99; 100; 101; 102; 103; 104; 105; 106; 107; 108; 109; 110; 111; 112; 113; 114; 115; 116; 117; 118; 119; 120; 121; 122; 123; 124; 125; 126; 127; 128; 129; 130; 131; 132; 133; 134; 135; 136; 137; 138; 139; 140; 141; 142; 143; 144; 145; 146; 147; 148; 149; 150; 151; 152; 153; 154; 155; 156; 157; 158; 159; 160; 161; 162; 163; 164; 165; 166; 167; 168; 169; 170; 171; 172; 173; 174; 175; 176; 177; 178; 179; 180; 181; 182; 183; 184; 185; 186; 187; 188; 189; 190; 191; 192; 193; 194; 195; 196; 197; 198; 199; 200; 201; 202; 203; 204; 205; 206; 207; 208; 209; 210; 211; 212; 213; 214; 215; 216; 217; 218; 219; 220; 221; 222; 223; 224; 225; 226; 227; 228; 229; 230; 231; 232; 233; 234; 235; 236; 237; 238; 239; 240; 241; 242; 243; 244; 245; 246; 247; 248; 249; 250; 251; 252; 253; 254
                   allowed-VIF-devices (SRO): 1; 2; 3; 4; 5; 6
                        possible-hosts ( RO): 5c72d261-e392-4b2b-ac24-e87dfd65343e; 0cca9a04-da39-4d20-8405-83482039e833
                           domain-type ( RW): hvm
                   current-domain-type ( RO): unspecified
                       HVM-boot-policy ( RW): BIOS order
                       HVM-boot-params (MRW): order: ncd; firmware: bios
                 HVM-shadow-multiplier ( RW): 1.000
                             PV-kernel ( RW): 
                            PV-ramdisk ( RW): 
                               PV-args ( RW): 
                        PV-legacy-args ( RW): 
                         PV-bootloader ( RW): 
                    PV-bootloader-args ( RW): 
                   last-boot-CPU-flags ( RO): vendor: GenuineIntel; features: 1fcbfbff-97ba2223-2d93fbff-00000403-00000001-00000000-00000000-00000000-00001000-9c000400-00000000-00000000-00000000-00000000
                      last-boot-record ( RO): ''
                           resident-on ( RO): <not in database>
                              affinity ( RW): <not in database>
                          other-config (MRW): base_template_name: Debian Buster 10.0; import_task: OpaqueRef:4d97169c-8b7e-465f-8785-8100ff249855; mac_seed: b1cd4665-0870-54ca-528b-fb2559cd302e; install-methods: cdrom,nfs,http,ftp; linux_template: true
                                dom-id ( RO): -1
                       recommendations ( RO): <restrictions><restriction field="memory-static-max" max="1649267441664"/><restriction field="vcpus-max" max="32"/><restriction field="has-vendor-device" value="false"/><restriction field="allow-gpu-passthrough" value="1"/><restriction field="allow-vgpu" value="1"/><restriction field="allow-network-sriov" value="1"/><restriction field="supports-bios" value="yes"/><restriction field="supports-uefi" value="no"/><restriction field="supports-secure-boot" value="no"/><restriction max="255" property="number-of-vbds"/><restriction max="7" property="number-of-vifs"/></restrictions>
                         xenstore-data (MRW): vm-data: ; vm-data/mmio-hole-size: 268435456
            ha-always-run ( RW) [DEPRECATED]: false
                   ha-restart-priority ( RW): 
                                 blobs ( RO): 
                            start-time ( RO): 19700101T00:00:00Z
                          install-time ( RO): 19700101T00:00:00Z
                          VCPUs-number ( RO): 0
                     VCPUs-utilisation (MRO): 
                            os-version (MRO): 
                    PV-drivers-version (MRO): 
    PV-drivers-up-to-date ( RO) [DEPRECATED]: false
                                memory (MRO): 
                                 disks (MRO): 
                                  VBDs (SRO): ce716461-e6a5-3acc-1c91-7d56e75923a3
                              networks (MRO): 
                   PV-drivers-detected ( RO): false
                                 other (MRO): platform-feature-multiprocessor-suspend: 1; has-vendor-device: 0
                                  live ( RO): true
            guest-metrics-last-updated ( RO): 20200704T16:54:46Z
                   can-use-hotplug-vbd ( RO): unspecified
                   can-use-hotplug-vif ( RO): unspecified
              cooperative ( RO) [DEPRECATED]: true
                                  tags (SRW): 
                             appliance ( RW): <not in database>
                     snapshot-schedule ( RW): <not in database>
                      is-vmss-snapshot ( RO): false
                           start-delay ( RW): 0
                        shutdown-delay ( RW): 0
                                 order ( RW): 0
                               version ( RO): 0
                         generation-id ( RO): 
             hardware-platform-version ( RO): 0
                     has-vendor-device ( RW): false
                       requires-reboot ( RO): false
                       reference-label ( RO): debian-10
                          bios-strings (MRO): bios-vendor: Xen; bios-version: ; system-manufacturer: Xen; system-product-name: HVM domU; system-version: ; system-serial-number: ; enclosure-asset-tag: ; hp-rombios: ; oem-1: Xen; oem-2: MS_VM_CERT/SHA1/bdbeb6e0a816d43fa6d3fe8aaef04c2bad9d3e3d
                     pending-guidances ( RO): 
                                 vtpms ( RO):

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

No branches or pull requests

3 participants