XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    terraform: XO response: jsonrpc2: code 10 message

    Scheduled Pinned Locked Moved Infrastructure as Code
    6 Posts 4 Posters 613 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      twaapo
      last edited by

      Using terraform module and creating a VM with diskless template and installation_method = "network" causes some problem. I worked around it by modifying the terraform module as follows:

      XOA: Current version: 5.86.1
      Terraform Provider version 0.25.1

      default

      vm.create
      {
        "CPUs": 4,
        ..
        "installation": {
          "method": "network",
          "repository": ""
        },
        "memoryMax": 6442450944,
        ..
      }
      {
        "code": 10,
        "data": {
          "errors": [
            {
              "instancePath": "/installation/repository",
              "schemaPath": "#/properties/installation/properties/repository/minLength",
              "keyword": "minLength",
              "params": {
                "limit": 1
              },
              "message": "must NOT have fewer than 1 characters"
            }
          ]
        },
        "message": "invalid parameters",
        "name": "XoError",
        "stack": "XoError: invalid parameters
          at Module.invalidParameters (/usr/local/lib/node_modules/xo-server/node_modules/xo-common/src/api-errors.js:21:32)
          at Xo.call (file:///usr/local/lib/node_modules/xo-server/src/xo-mixins/api.mjs:65:20)
          at Api.#callApiMethod (file:///usr/local/lib/node_modules/xo-server/src/xo-mixins/api.mjs:413:19)"
      }
      

      nulled out "repository"

      vm.create
      {
        "CPUs": 4,
        ..
        "installation": {
          "method": "network"
        },
        "memoryMax": 6442450944,
        ..
      }
      {
        "code": 10,
        "data": {
          "errors": [
            {
              "instancePath": "/installation",
              "schemaPath": "#/properties/installation/required",
              "keyword": "required",
              "params": {
                "missingProperty": "repository"
              },
              "message": "must have required property 'repository'"
            }
          ]
        },
        "message": "invalid parameters",
        "name": "XoError",
        "stack": "XoError: invalid parameters
          at Module.invalidParameters (/usr/local/lib/node_modules/xo-server/node_modules/xo-common/src/api-errors.js:21:32)
          at Xo.call (file:///usr/local/lib/node_modules/xo-server/src/xo-mixins/api.mjs:65:20)
          at Api.#callApiMethod (file:///usr/local/lib/node_modules/xo-server/src/xo-mixins/api.mjs:413:19)"
      }
      

      For some reason I typed repository: "none". In next test and that worked fine, and I dont have the log for that. I think maybe XO should accept the nulled repository field or empty string what the terraform module is producing now, if "method: network" is specified.

      1 Reply Last reply Reply Quote 0
      • olivierlambertO olivierlambert moved this topic from Xen Orchestra on
      • gudge25G Offline
        gudge25
        last edited by

        can you share your .tf file ?

        T 1 Reply Last reply Reply Quote 0
        • T Offline
          twaapo @gudge25
          last edited by

          I was trying to boot flatcar linux diskless too, but then realised I probably need a disk anyway. So there is a disk on all VMs now.

          The template is just the default "Other media" diskless template that came with XO.

          # get "other" template id from pool per vm
          data "xenorchestra_template" "other" {
            for_each   = var.hosts
            name_label = "Other install media"
            pool_id    = each.value.pool_id
          }
          
          resource "xenorchestra_vm" "flatcar" {
            for_each            = var.hosts
            auto_poweron        = true
            installation_method = "network"
            name_label          = each.key
            memory_max          = each.value.memory * 1024 * 1024 * 1024
            cpus                = each.value.cores
            name_description = format("tf-flatcar: %dC %dMiB %dG",
              each.value.cores,
              each.value.memory * 1024,
            contains(keys(each.value), "disk") ? each.value.disk : 0)
            template = data.xenorchestra_template.other[each.key].id
            tags     = []
            network {
              network_id = var.net.id
            }
            lifecycle {
              ignore_changes = [
                destroy_cloud_config_vdi_after_boot,
                disk,
                template,
                vga,
                videoram,
                affinity_host,
              ]
            }
          
            # possibly support diskless flatcar in the future
            disk {
              sr_id            = contains(keys(each.value), "disk") ? var.sr.id : "xxx"
              name_label       = contains(keys(each.value), "disk") ? format("%s-root", each.key) : "xxxx"
              name_description = contains(keys(each.value), "disk") ? format("%s-root", each.key) : "xxxx"
              size             = contains(keys(each.value), "disk") ? each.value.disk * 1024 * 1024 * 1024 : 0
            }
            timeouts {}
          }
          
          variable "hosts" {
            type = map(object({
              cores   = number
              memory  = number # in G
              disk    = number # in G
              pool_id = string
            }))
          }
          
          D 1 Reply Last reply Reply Quote 0
          • D Offline
            ddelnano Terraform Team @twaapo
            last edited by

            @twaapo are you able to share the full error of your terraform apply command? In addition to that it would be helpful to see the TF_LOG=DEBUG terraform apply output as well.

            Please be aware that you might need to sanitize the output.

            T 1 Reply Last reply Reply Quote 0
            • T Offline
              twaapo @ddelnano
              last edited by

              @ddelnano

              2023-11-02T17:38:39.404+0200 [INFO]  provider.terraform-provider-xenorchestra_v0.25.1: 2023/11/02 17:38:39 [TRACE] Made rpc call `vm.create` with params: map[CPUs:4 VDIs:[map[$SR:7d62dcc9-3fbb-3e4d-af51-07689cb846a6 SR:7d62dcc9-3fbb-3e4d-af51-07689cb846a6 name_description:faction-root name_label:faction-root size:6442450944 type:user]] VIFs:[map[network:37975edd-c276-5539-391f-bd2c042f1876]] auto_poweron:true bootAfterCreate:true coreOs:false cpuCap:<nil> cpuWeight:<nil> existingDisks:map[] expNestedHvm:false high_availability: hvmBootFirmware:bios installation:map[method:network repository:] memoryMax:6442450944 name_description:tf-flatcar: 4C 6144MiB 6G name_label:faction tags:[] template:22d986f1-847f-c23c-8cdf-2a38fb024da9-552bce37-51b2-445d-84f2-5f33fa112d7e vga:std videoram:8] and received : result with error: jsonrpc2: code 10 message: invalid parameters: timestamp="2023-11-02T17:38:39.404+0200"
              2023-11-02T17:38:39.404+0200 [ERROR] provider.terraform-provider-xenorchestra_v0.25.1: Response contains error diagnostic: diagnostic_summary="jsonrpc2: code 10 message: invalid parameters: {\"errors\":[{\"instancePath\":\"/installation/repository\",\"schemaPath\":\"#/properties/installation/properties/repository/minLength\",\"keyword\":\"minLength\",\"params\":{\"limit\":1},\"message\":\"must NOT have fewer than 1 characters\"}]}" tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_severity=ERROR tf_proto_version=5.4 tf_provider_addr=provider diagnostic_detail="" tf_req_id=28a2312a-e508-5aad-50d3-e43a41d1eddf tf_resource_type=xenorchestra_vm @module=sdk.proto timestamp="2023-11-02T17:38:39.404+0200"
              2023-11-02T17:38:39.408+0200 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
              2023-11-02T17:38:39.408+0200 [ERROR] vertex "module.flatcars.xenorchestra_vm.flatcar[\"faction\"]" error: jsonrpc2: code 10 message: invalid parameters: {"errors":[{"instancePath":"/installation/repository","schemaPath":"#/properties/installation/properties/repository/minLength","keyword":"minLength","params":{"limit":1},"message":"must NOT have fewer than 1 characters"}]}
              ╷
              │ Error: jsonrpc2: code 10 message: invalid parameters: {"errors":[{"instancePath":"/installation/repository","schemaPath":"#/properties/installation/properties/repository/minLength","keyword":"minLength","params":{"limit":1},"message":"must NOT have fewer than 1 characters"}]}
              │
              │   with module.flatcars.xenorchestra_vm.flatcar["faction"],
              │   on flatcar/main.tf line 13, in resource "xenorchestra_vm" "flatcar":
              │   13: resource "xenorchestra_vm" "flatcar" {
              │
              ╵
              2023-11-02T17:38:39.412+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
              2023-11-02T17:38:39.412+0200 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
              2023-11-02T17:38:39.412+0200 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.4.0/linux_amd64/terraform-provider-local_v2.4.0_x5 pid=79007
              2023-11-02T17:38:39.412+0200 [DEBUG] provider: plugin exited
              2023-11-02T17:38:39.412+0200 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/terra-farm/xenorchestra/0.25.1/linux_amd64/terraform-provider-xenorchestra_v0.25.1 pid=78994
              2023-11-02T17:38:39.412+0200 [DEBUG] provider: plugin exited
              

              Is this enough or maybe I need to paste the whole dump somewhere? Theres a LOT of debug output.

              AtaxyaNetworkA 1 Reply Last reply Reply Quote 0
              • AtaxyaNetworkA Offline
                AtaxyaNetwork Ambassador @twaapo
                last edited by

                @twaapo @ddelnano Hi !

                I think the problem is here:

                installation:map[method:network repository:]
                

                You need to have some value for the var "repository"

                After some digging in internet, XAPI code (because why not), I found the solution in an old commit in the XO repo:
                https://github.com/vatesfr/xen-orchestra/commit/07bf93e022a0026cacf28bf8797646361f7ea4a6

                I think the var need to be set to "pxe"
                (i'm doing some more digging)

                0 julien-f committed to vatesfr/xen-orchestra
                Add PXE installation method for HVM templates. (fix #436)
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post