luthermonson / go-proxmox

Go client with types and tests for the Proxmox-VE REST API
Apache License 2.0
158 stars 48 forks source link

Cloud-init Fails #68

Closed mcbenjemaa closed 1 year ago

mcbenjemaa commented 1 year ago

After adding the iso the first time, the second run fails:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x104837bb0]

goroutine 1 [running]: github.com/luthermonson/go-proxmox.(Task).Ping(0x0) /Users/mbenjemaa/workspace/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-alpha3/tasks.go:39 +0x20 github.com/luthermonson/go-proxmox.(Task).Wait(0x0, 0x3b9aca00, 0x77359400) /Users/mbenjemaa/workspace/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-alpha3/tasks.go:145 +0x2c github.com/luthermonson/go-proxmox.(Task).WaitFor(...) /Users/mbenjemaa/workspace/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-alpha3/tasks.go:140 github.com/luthermonson/go-proxmox.(VirtualMachine).CloudInit(0x140001980e0, {0x104844d81, 0x4}, {0x10485df67, 0x1ed}, {0x10485df67, 0x1ed}) /Users/mbenjemaa/workspace/go/pkg/mod/github.com/luthermonson/go-proxmox@v0.0.0-alpha3/virtual_machine.go:149 +0x1a8

luthermonson commented 1 year ago

the stack trace is saying this is coming from pinging a task and i think it's missing a client when it tries to do that. can you give me some code example on how you are using this?

mcbenjemaa commented 1 year ago

I just have the example for the Cloud init on the second run it fails.

Basically, in the WaitFor

mcbenjemaa commented 1 year ago

I will paste code tomorrow

mcbenjemaa commented 1 year ago
resp, err := proxmoxClient.GetVM("pve", 102)
if err != nil {
panic(err)
}

logger.Info("VM, ", resp.Name)

userData := `hostname: proxmox-control-plane
manage_etc_hosts: true
user: ionos
password: ...
ssh_authorized_keys:
  - >-
    .....
chpasswd:
  expire: false
users:
  - default
package_upgrade: true
network:
  version: 1
  config:
    - type: physical
      name: eth0
      subnets:
        - type: static
          address: 10.10.10.66/32
          gateway: 10.10.10.1`

err = resp.CloudInit("ide0", userData, metadata)
if err != nil {
logger.Error(err, "unable to create iso ")
}

run this twice, and in the second run, you get a runtime panic.

luthermonson commented 1 year ago

i will merge and cut a new alpha when we fix the other outstanding issue with the cpu float32... feel free to try my code change and see if it fixes your issue. it stemmed from the second call to add tag being a noop and returning a nil task. good catch!

mcbenjemaa commented 1 year ago

exactly the task for setting the tag is failing