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

fix(lxc): unmarshal string/int vmid as int when read container status #622

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

zamrih
Copy link
Contributor

@zamrih zamrih commented Oct 16, 2023

Contributor's Note

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated templates in /example for any new or updated resources / data sources.
  • I have ran make example to verify that the change works as expected.

The PR fixes an unmarshal error of the returned vmid of an LXC container nodes/{node}/lxc/{vmid}/status/current.
There is an existing types.CustomInt common type that already implements the correct un/marshal interfaces.
Those common types do not appear to be unit tested but I figured they're around since a while.
It would probably be better to add some container_types_test.go for it though.
Not sure how the PVE REST API deals with the a vm as opposed to an LXC container but the fix might apply there as well.

Proof of Work

Before:

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" {
│ 
╵

After:

module.container.random_password.container_password: Refreshing state... [id=none]
module.container.proxmox_virtual_environment_container.container: Refreshing state... [id=506]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.container.proxmox_virtual_environment_container.container is tainted, so must be replaced
-/+ resource "proxmox_virtual_environment_container" "container" {
      ~ id            = "506" -> (known after apply)
      - tags          = [] -> null
        # (6 unchanged attributes hidden)

      ~ network_interface {
          - mac_address = "**:**:**:**:**:**" -> null
            name        = "eth0"
            # (6 unchanged attributes hidden)
        }

        # (5 unchanged blocks hidden)
    }
...

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #621

Signed-off-by: zamrih <ramzi.hb@gmail.com>
@bpg bpg changed the title Support unmarshal of string vmid on LXC current status request fix(lxc): unmarshal string/int vmid as int when read container status Oct 17, 2023
Copy link
Owner

@bpg bpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zamrih! 👋🏼

Thanks a lot of the fix!

LGTM! 🚀

@bpg bpg merged commit b90445a into bpg:main Oct 17, 2023
8 checks passed
@ghost ghost mentioned this pull request Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot import/refresh LXC container with unmarshal error
2 participants