Telmate / terraform-provider-proxmox

Terraform provider plugin for proxmox
MIT License
2.13k stars 512 forks source link

Error: The terraform-provider-proxmox_v2.9.14 plugin crashed! (Proxmox 8.0.4 latest update) #863

Closed AlexKastrytski closed 3 months ago

AlexKastrytski commented 10 months ago

Stack trace from the terraform-provider-proxmox_v2.9.14 plugin:

panic: interface conversion: interface {} is string, not float64

goroutine 45 [running]: github.com/Telmate/proxmox-api-go/proxmox.NewConfigQemuFromApi(0xc000518718, 0xc9d509?) github.com/Telmate/proxmox-api-go@v0.0.0-20230319185744-e7cde7198cdf/proxmox/config_qemu.go:584 +0x4605 github.com/Telmate/terraform-provider-proxmox/proxmox.resourceVmQemuCreate(0xc0002e2c00, {0xb66f60?, 0xc00014bcc0}) github.com/Telmate/terraform-provider-proxmox/proxmox/resource_vm_qemu.go:972 +0x2c4d github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).create(0xdd7840?, {0xdd7840?, 0xc0003eaf00?}, 0xd?, {0xb66f60?, 0xc00014bcc0?}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:695 +0x178 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).Apply(0xc000208ee0, {0xdd7840, 0xc0003eaf00}, 0xc0004e0f70, 0xc0002e2a80, {0xb66f60, 0xc00014bcc0}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:837 +0xa85 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ApplyResourceChange(0xc00045fe60, {0xdd7840?, 0xc0003eade0?}, 0xc000238640) github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:1021 +0xe8d github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ApplyResourceChange(0xc000492000, {0xdd7840?, 0xc0003ea3c0?}, 0xc0002363f0) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:818 +0x574 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xc6bc20?, 0xc000492000}, {0xdd7840, 0xc0003ea3c0}, 0xc000236070, 0x0) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0xc0002d01e0, {0xddb420, 0xc0001029c0}, 0xc0005da480, 0xc000477170, 0x128f7a0, 0x0) google.golang.org/grpc@v1.53.0/server.go:1336 +0xd23 google.golang.org/grpc.(Server).handleStream(0xc0002d01e0, {0xddb420, 0xc0001029c0}, 0xc0005da480, 0x0) google.golang.org/grpc@v1.53.0/server.go:1704 +0xa2f google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.53.0/server.go:965 +0x98 created by google.golang.org/grpc.(Server).serveStreams.func1 google.golang.org/grpc@v1.53.0/server.go:963 +0x28a

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

jm-bertheas-datailor commented 10 months ago

Exactly same issue! This problem appears for me after migrating from Proxmox VE 8.0.3 to 8.0.4

AndrewGolikov55 commented 10 months ago

Same:

This problem appears for me after migrating from Proxmox VE 8.0.3 to 8.0.4

MrDuck2742 commented 10 months ago

Same here after upgrading Proxmox VE 8.0.3 to 8.0.4

Downgrading Proxmox VE to 8.0.3 did not resolve the issue - same panic when applying:

Stack trace from the terraform-provider-proxmox_v2.9.14 plugin:

panic: interface conversion: interface {} is string, not float64

goroutine 135 [running]: github.com/Telmate/proxmox-api-go/proxmox.NewConfigQemuFromApi(0x1400018ea20, 0xf?) github.com/Telmate/proxmox-api-go@v0.0.0-20230319185744-e7cde7198cdf/proxmox/config_qemu.go:584 +0x3b34 github.com/Telmate/terraform-provider-proxmox/proxmox.prepareDiskSize(0x0?, 0x14000038378?, 0x11?, 0x1400019c2a0?) github.com/Telmate/terraform-provider-proxmox/proxmox/resource_vm_qemu.go:1737 +0x98 github.com/Telmate/terraform-provider-proxmox/proxmox.resourceVmQemuCreate(0x1400054c300, {0x105519ee0?, 0x140003a2370}) github.com/Telmate/terraform-provider-proxmox/proxmox/resource_vm_qemu.go:1059 +0x158c github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).create(0x1056569a0?, {0x1056569a0?, 0x140006522a0?}, 0xd?, {0x105519ee0?, 0x140003a2370?}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:695 +0x134 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).Apply(0x140004367e0, {0x1056569a0, 0x140006522a0}, 0x1400009ec30, 0x14000408180, {0x105519ee0, 0x140003a2370}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:837 +0x86c github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ApplyResourceChange(0x140004c0b88, {0x1056569a0?, 0x14000652180?}, 0x140001800f0) github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:1021 +0xb70 github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ApplyResourceChange(0x140001a63c0, {0x1056569a0?, 0x14000809650?}, 0x1400028a380) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:818 +0x3b8 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x10561fa60?, 0x140001a63c0}, {0x1056569a0, 0x14000809650}, 0x1400028a310, 0x0) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0x140004d8000, {0x10565a540, 0x140000eeea0}, 0x1400054efc0, 0x140004dac60, 0x105af7860, 0x0) google.golang.org/grpc@v1.53.0/server.go:1336 +0xb7c google.golang.org/grpc.(Server).handleStream(0x140004d8000, {0x10565a540, 0x140000eeea0}, 0x1400054efc0, 0x0) google.golang.org/grpc@v1.53.0/server.go:1704 +0x82c google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.53.0/server.go:965 +0x84 created by google.golang.org/grpc.(Server).serveStreams.func1 google.golang.org/grpc@v1.53.0/server.go:963 +0x290

Error: The terraform-provider-proxmox_v2.9.14 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

jm-bertheas-datailor commented 10 months ago

I found the problem by debugging the provider. Some "memory" values in QemuConfig returned from proxmox API are sometimes float64, and sometimes string

I temporary and locally fixed the problem in the proxmox-api-go library, into config_qemu.go file, function NewConfigQemuFromApi by replacing this part of code:

    if _, isSet := vmConfig["memory"]; isSet {
        switch vmConfig["memory"].(type) {
    }

by

    if _, isSet := vmConfig["memory"]; isSet {
        switch vmConfig["memory"].(type) {
        case float64:
            memory = vmConfig["memory"].(float64)
        case string:
            memory2, err := strconv.ParseFloat(vmConfig["memory"].(string), 64)
            if err != nil {
                log.Fatal(err)
                return nil, err
            } else {
                memory = memory2
            }
        }
    }
yokozu777 commented 10 months ago

Same problem Linux 6.2.16-19-pve pve-manager/8.0.4

Stack trace from the terraform-provider-proxmox_v2.9.14 plugin:

panic: interface conversion: interface {} is string, not float64

cerhades commented 10 months ago

I also experienced this same error today. Proxmox version 8.0.4

MrDuck2742 commented 10 months ago

@jm-bertheas-datailor

Thanks for the info.

Trying to work out how to make the changes you have suggested but cannot find the code in the file from the proxmox-api-go library repository, here: Telmate/proxmox-api-go

I have located the file and function but cannot locate the code to replace.

Perhaps you could expand upon the details you have provided? I must be looking in the wrong place.

jm-bertheas-datailor commented 10 months ago

@MrDuck2742 You're welcome.

I did the fix on the v2.9.14 of terraform-provider-proxmox and I saw that Telmate/proxmox-api-go was not in the last version of the main branch... I think that Telmate/proxmox-api-go was modified since the build of v2.9.14 of terraform-provider-proxmox...

On v2.9.14 Tag: require ( github.com/Telmate/proxmox-api-go v0.0.0-20230319185744-e7cde7198cdf

On main branch: require ( github.com/Telmate/proxmox-api-go v0.0.0-20230616173359-03f4e428f6c6

Is it possible to make a patch on v2.9.14 its used version of Telmate/proxmox-api-go? the problem is blocking...

TheGameProfi commented 10 months ago

It should be possible, but since the last update on the Repo and activity of an member is months old, i would assume that the Repo is dead. Also the telmate website isn't available anymore. The best way would be to fork a new Repo and fix it there.

yokozu777 commented 10 months ago

will rolling back to the version Linux 6.2.16-18-pve help?

TheGameProfi commented 10 months ago

To my knowledge the problem only happens with pve 8.0.4, because they changed their api. So changing the version should help, but I think you're required to reinstall pve to downgrade.

I will also try to fork it and fix it. But i can't promise anything.

AlexKastrytski commented 10 months ago

I installed olde Proxmox 7.3.3 and Provider worked. I suggest that issue in new qemu-server and pve-qemu-kvm? but this tools dont easy to downgrade :( conf

rfdrew commented 10 months ago

Im build provider with fix from jm-bertheas-datailor and its work correctly Thank you

pROTTotype21 commented 10 months ago

I have the same problem after upgrading to Proxmox 8.0.4 with telmate/proxmox version 2.9.11.

GTL (Telmat.com) is now ViaPath. Does this project have a future or is it dead for good? https://www.gtl.net/about-us/press-and-news/gtl-becomes-viapath-technologies/

TheGameProfi commented 10 months ago

I think the Project from the original Team is dead, so it depends on the community to continue this Project.

frostyfab commented 10 months ago

Frosty news everyone! I've put together a quick workaround that worked for me.

Binary & steps for Linux x86-64 (other OS/arch ā†“ scroll down):

terraform-provider-proxmox.tar.gz

# prepare the binary/directories
cd /tmp
wget https://github.com/frostyfab/terraform-provider-proxmox/blob/fix-memory-type-proxmox-8.0.4-workaround/terraform-provider-proxmox.tar.gz
tar -xf terraform-provider-proxmox.tar.gz
chmod +x terraform-provider-proxmox
mkdir -p ~/.terraform.d/plugins/terraform.local/local/frostyfab/2.9.14/linux_amd64/

# renaming the binary here
cp  terraform-provider-proxmox ~/.terraform.d/plugins/terraform.local/local/frostyfab/2.9.14/linux_amd64/terraform-provider-frostyfab_v2.9.14 

# šŸ‰ HERE BE DRAGONS šŸ‰
# edit ~/.terraformrc manually if you have anything in it, otherwise:

cp ~/.terraformrc{,.bak}

echo 'provider_installation {
  filesystem_mirror {
    path    = "'$HOME'/.terraform.d/plugins"
  }
  direct {
    exclude = ["terraform.local/*/*"]
  }
}' >> ~/.terraformrc

# in project change your required_providers to:

proxmox = {
  source  = "terraform.local/local/frostyfab" # FIXME: remove this when https://github.com/Telmate/terraform-provider-proxmox/issues/863 is resolved
  version = "~> 2.9"
}

# run 
terraform init

If you run another OS/arch you need to build the binary:

haters > /dev/null

pROTTotype21 commented 10 months ago

Thanks for the quick fix @frostyfab. It works for me for now. Hope the project survives.

MrDuck2742 commented 10 months ago

@jm-bertheas-datailor

Thanks again ...

I noticed the version difference when trying to work out how to manipulate the local go library.

I am also using kreuzwerker/m1-terraform-provider-helper which compiles an darwin_arm64 image for my M1 MacBook. So I guess I will need to play with this in order to get the correct library version to compile then play with the library somehow. I know very little about go ...

Need to read the rest of the posts here too.

MrDuck2742 commented 10 months ago

@frostyfab

Working on M1 MacBook with darwin_arm64 binary as per your instructions above.

Many thanks!

yokozu777 commented 10 months ago

Should I wait official update telmate/proxmox 2.9.15?

TheGameProfi commented 10 months ago

There will probably be no new version, or at least not soon. Since the last activity are about 6 months old.

loeken commented 10 months ago

@frostyfab do you have any plans to maintain/publish (on terraform.io) your fork?

frostyfab commented 10 months ago

@loeken šŸ‘Ž No I don't have plans to maintain it (nor the xp)

šŸ“¦ If people build binaries for other OS/arch I can publish and link them in the git repo!

frostyfab commented 10 months ago

Cool I think @TuncTaylan just volunteered to maintain the package?

scr

There are ~150 commits for the next release to go through and 60 issues/pull requests. Can you have it done by tomorrow? Thanks

loeken commented 10 months ago
terraform {
    required_providers {
        proxmox = {
            source = "loeken/proxmox"
            version = "2.9.16"
        }
    }
}

i forked master from this repo, applied the patch to the memory section and published a terraform module ( dont plan on taking over this repo either :p )

yokozu777 commented 10 months ago

whose project?

terraform { required_providers { proxmox = { source = "loeken/proxmox" version = "2.9.16" } } }

loeken commented 10 months ago

@yokozu777 https://github.com/loeken/terraform-provider-proxmox is a fork of this repo with the fix applied i published it to https://registry.terraform.io/providers/loeken/proxmox/2.9.16 so you can use that till Telmate fixes this repo ( or somebody forks it )

yokozu777 commented 10 months ago

has it been checked with pve-manager version 8.0.9 ?

yokozu777 commented 10 months ago

i build localy terraform-provider-proxmox how to specify locally proxmox-api-go?

change in go.mod require ( github.com/Telmate/proxmox-api-go

to local folder?

TheGameProfi commented 10 months ago

@yokozu777 i not completely sure but this should do it: replace github.com/Telmate/proxmox-api-go => ./local/path/to/proxmox-api-go add this to the end of the go.mod file

frostyfab commented 10 months ago

@loeken

i forked master from this repo, applied the patch to the memory section and published a terraform module ( dont plan on taking over this repo either :p )

Wow you went the extra mile, works great šŸ‘šŸ‘šŸ‘šŸ‘

Thanks a lot, have some cream!

yokozu777 commented 10 months ago

added to /go/terraform-provider-proxmox/go.mod replace github.com/Telmate/proxmox-api-go => /go/proxmox-api-go/

got an error

github.com/Telmate/terraform-provider-proxmox/proxmox proxmox/resource_vm_qemu.go:973:3: unknown field Smbios1 in struct literal of type "github.com/Telmate/proxmox-api-go/proxmox".ConfigQemu proxmox/resource_vm_qemu.go:1288:3: unknown field Smbios1 in struct literal of type "github.com/Telmate/proxmox-api-go/proxmox".ConfigQemu proxmox/resource_vm_qemu.go:1652:40: config.Smbios1 undefined (type *"github.com/Telmate/proxmox-api-go/proxmox".ConfigQemu has no field or method Smbios1)

aleprovencio commented 10 months ago

I'm trying loeken/proxmox on Proxmox 8.0.9 and terraform apply never finishes due to a boot loop noticed on the Proxmox console

rlaflamme commented 10 months ago

Tried loeken/proxmox on Proxmox 8.0.9 and it works

VirtualDisk commented 10 months ago

I'm trying loeken/proxmox on Proxmox 8.0.9 and terraform apply never finishes due to a boot loop noticed on the Proxmox console

Same issue here using a VM clone and a cloud-init script. Disk isn't bootable anymore. Uh-oh!

TuncTaylan commented 10 months ago

I have the same issue, the cloned image disk turns into unused disk and a new empty disk is created, hence the boot loop.

TheGameProfi commented 10 months ago

@aleprovencio @VirtualDisk @TuncTaylan would probably be the best to create a new issue either on this repo or if possible directly on loeken's repo

lazywebm commented 10 months ago

I'm trying loeken/proxmox on Proxmox 8.0.9 and terraform apply never finishes due to a boot loop noticed on the Proxmox console

Same issue here using a VM clone and a cloud-init script. Disk isn't bootable anymore. Uh-oh!

Likely due to https://github.com/Telmate/terraform-provider-proxmox/issues/704, which is affecting my setup as well. That's why I was using an older version of the Telmate provider (v2.9.11) up until now.

@loeken would you perhaps be able to backport the crash fix (scope of this ticket) to the older Telmate provider version? Or alternatively, if you or anyone else has resources to fix the cloud-init issue, that would be awesome.

TheGameProfi commented 10 months ago

@loeken My Question is now, do you intend on working on the errors from this Provider. Or do want "nothing" to do with it anymore?

rlaflamme commented 10 months ago

Tried loeken/proxmox on Proxmox 8.0.9 and it works it works. . but this provider fallss short with its state ... it is not idempotent. It screwed itself after applying the same plan! Please, We need an update to this one

M0NsTeRRR commented 10 months ago

Hello,

I've migrated today to the other proxmox provider and it works far better than this one as this project seems dead. I've updated my Virtual Machine module with cloud init to the new provider, it's not a lot of works to migrate if you are interested to look, my commit is here I'm using proxmox 8.0.9 so I can confirm it works on latest version :)

Regards,

PS: Thanks Telmate for your open source provider that I have used all this time

jm-bertheas-datailor commented 10 months ago

Same conclusion for me: using bpg/proxmox provider with OpenTofu on Proxmox 8.0.9 works well too for me.

frostyfab commented 10 months ago

The bpg terraform provider seems pretty good! Migration was a breeze thanks @jm-bertheas-datailor

One big issue I had was slow cloning of huge VM templates. But there is a undocumented flag for that too.

clone {
    vm_id = 6969  # nice
    full  = false # undocumented https://github.com/bpg/terraform-provider-proxmox/issues/551
}

Its a gg for me with Telmate provider!

fulljackz commented 10 months ago

I'm trying loeken/proxmox on Proxmox 8.0.9 and terraform apply never finishes due to a boot loop noticed on the Proxmox console

Same issue here using a VM clone and a cloud-init script. Disk isn't bootable anymore. Uh-oh!

Hi there, the same on my side with cloud init too. Vm clone and boot is ok but it loops on boot

loeken commented 10 months ago

yeah i tested cloning my template without touching the disk {} section which did work, I can confirm it fails for me when adjusting the disk too.

you can use this one if you dont touch the disk {} block ( and you can use qm resize to resize successfully afterwards )

I do not want to invest time in fixing the provider i will also switch to https://github.com/bpg/terraform-provider-proxmox

rlaflamme commented 10 months ago

Another happy user: bpg/proxmox provider with OKD 4,14 on Proxmox 8.0.9 works well too for me.

TuncTaylan commented 10 months ago

It seems that the provider from bpg needs SSH access with API key. Can someone confirm this?

M0NsTeRRR commented 10 months ago

It seems that the provider from bpg needs SSH access with API key. Can someone confirm this?

No you can use your login/password or an API token. SSH agent is used for certain tasks. You have everything here

fulljackz commented 10 months ago

I confirm, I only use an API token and it works. Btw, I just migrated from telmate to bpg easily, changes are not so important. I had an error like with telmate and @loeken with a boot loop so I had to set "full clone" and it worked as supposed to :

  clone {
    datastore_id = "lv_thin"
    vm_id = "100"
  }
TuncTaylan commented 10 months ago

It seems that the provider from bpg needs SSH access with API key. Can someone confirm this?

No you can use your login/password or an API token. SSH agent is used for certain tasks. You have everything here

Yes, I read that. Take a look at "Note2:", that's what's not clear for me. Nevertheless I'll take a look at it. Thanks!