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

Cannot import/refresh LXC container with unmarshal error #621

Closed
zamrih opened this issue Oct 16, 2023 · 2 comments · Fixed by #622
Closed

Cannot import/refresh LXC container with unmarshal error #621

zamrih opened this issue Oct 16, 2023 · 2 comments · Fixed by #622
Labels
🐛 bug Something isn't working

Comments

@zamrih
Copy link
Contributor

zamrih commented Oct 16, 2023

Describe the bug
A container fails to be created/updated on creation/import.
The root cause is the PVE REST API returning a string vmid instead of an int:

{
  "data": {
    "pid": "114348",
    "diskread": 12240,
    "swap": 28311552,
    "lock": "",
    "netout": 73553,
    "cpu": 0.0048730102506797,
    "name": "container.example.com",
    "cpus": 4,
    "netin": 191704,
    "uptime": 2152,
    "type": "lxc",
    "status": "running",
    "diskwrite": 0,
    "disk": "2843205632",
    "maxswap": 536870912,
    "vmid": "506",
    "maxdisk": "8388009984",
    "mem": 257888256,
    "ha": {
      "managed": 0
    },
    "maxmem": 536870912,
    "template": ""
  }
}

To Reproduce
Steps to reproduce the behavior:

  1. Create an LXC container without terraform
  2. Add an import block
  3. Create a resource proxmox_virtual_environment_container with the existing vmid
  4. Run terraform plan
  5. See error

Please also provide a minimal Terraform configuration that reproduces the issue.

import {
  to = proxmox_virtual_environment_container.container
  id = "${var.pm_target_node}/${var.container_id}"
}

resource "proxmox_virtual_environment_container" "container" {
  node_name = var.pm_target_node
  vm_id     = var.container_id
  
  ...
}

Expected behavior
Go past the unmarshal error.

Screenshots
N/A

Additional context

  • Single or clustered Proxmox: Single
  • Provider version (ideally it should be the latest version): v0.34.0
  • Terraform version: v1.6.1
  • OS (where you run Terraform from): Ubuntu
  • Error logs (TF_LOG=ERROR terraform apply):
module.container.random_password.container_password: Refreshing state... [id=none]
module.container.proxmox_virtual_environment_container.container: Refreshing state... [id=506]

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: error retrieving container status: failed to decode HTTP GET response (path: nodes/nodelab/lxc/506/status/current) - Reason: json: cannot unmarshal string into Go struct field GetStatusResponseData.data.vmid of type int
│ 
│   with module.container.proxmox_virtual_environment_container.container,
│   on container/main.tf line 1, in resource "proxmox_virtual_environment_container" "container":
│    1: resource "proxmox_virtual_environment_container" "container" {
│ 
╵
@bpg
Copy link
Owner

bpg commented Oct 17, 2023

@all-contributors please add @zamrih for bug, code

@allcontributors
Copy link
Contributor

@bpg

I've put up a pull request to add @zamrih! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
2 participants