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

Plugin crashes when trying to decrease virtual machine's raw disk size #500

Open
rovilu opened this issue Oct 26, 2023 · 4 comments
Open

Comments

@rovilu
Copy link

rovilu commented Oct 26, 2023

Description

There is a possibility to add volatile disk to opennebula_virtual_machine resource, which shares the virtual machine's lifecycle. The documentation says that if size disk size value is changed on an existing resource, it must be bigger than the previous one.

If the new value is still smaller than the previous one, on "terraform apply", the plugin crashes producing a huge error log:

Stack trace from the terraform-provider-opennebula_v1.3.0 plugin:

panic: runtime error: index out of range [1] with length 1

goroutine 113 [running]:
github.com/OpenNebula/terraform-provider-opennebula/opennebula.updateDisk({0xe86ba8, 0xc0003067e0}, 0xc000163dc0?, {0xc44800?, 0xc000163dc0?})
github.com/OpenNebula/terraform-provider-opennebula/opennebula/resource_opennebula_virtual_machine.go:1724 +0x19b3
github.com/OpenNebula/terraform-provider-opennebula/opennebula.resourceOpennebulaVirtualMachineUpdateCustom({0xe86ba8, 0xc0003067e0}, 0xc00004c100, {0xc44800, 0xc000163dc0}, 0xd93038)
github.com/OpenNebula/terraform-provider-opennebula/opennebula/resource_opennebula_virtual_machine.go:1321 +0x2195
github.com/OpenNebula/terraform-provider-opennebula/opennebula.resourceOpennebulaVirtualMachineUpdate({0xe86ba8, 0xc0003067e0}, 0x0?, {0xc44800, 0xc000163dc0})
github.com/OpenNebula/terraform-provider-opennebula/opennebula/resource_opennebula_virtual_machine.go:1101 +0x39
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc000488540, {0xe86be0, 0xc000889bf0}, 0xd?, {0xc44800, 0xc000163dc0})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:741 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000488540, {0xe86be0, 0xc000889bf0}, 0xc00071a8f0, 0xc00004d600, {0xc44800, 0xc000163dc0})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:847 +0x82c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000223758, {0xe86be0?, 0xc000889ad0?}, 0xc000528730)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0003710e0, {0xe86be0?, 0xc0008892c0?}, 0xc00014c310)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xd08360?, 0xc0003710e0}, {0xe86be0, 0xc0008892c0}, 0xc00014c2a0, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003783c0, {0xe89de0, 0xc00050a1a0}, 0xc00040c5a0, 0xc0004a25a0, 0x13766c0, 0x0)
google.golang.org/[email protected]/server.go:1340 +0xd13
google.golang.org/grpc.(*Server).handleStream(0xc0003783c0, {0xe89de0, 0xc00050a1a0}, 0xc00040c5a0, 0x0)
google.golang.org/[email protected]/server.go:1713 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-opennebula_v1.3.0 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.

Terraform and Provider version

Terraform v1.6.2
OpenNebula provider v1.3.0

Affected resources and data sources

opennebula_virtual_machine

Terraform configuration

No response

Expected behavior

Error is raised by the plugin telling that the disk size value should be bigger than the previous one.

Actual behavior

The plugin crashes.

Steps to Reproduce

  1. Create "opennebula_virtual_machine" resource with raw disk of a random size, e.g. using sample:
resource "opennebula_virtual_machine" "test" {
....

  disk {
    size            = 10240
    driver          = "raw"
    dev_prefix      = "sd"
    volatile_type   = "fs"
    volatile_format = "raw"
  }

....
  1. Create the virtual machine (terraform plan; terraform apply)
  2. Change the "size" parameter value in the "disk" block to the smaller one, e.g.
....
  disk {
    size            = 5120
    driver          = "raw"
    dev_prefix      = "sd"
    volatile_type   = "fs"
    volatile_format = "raw"
  }
.....
  1. Apply changes (terraform plan; terraform apply) (multiple times if needed)
  2. Enjoy the errors.

Debug output

No response

Panic output

No response

Important factoids

No response

References

No response

Copy link

This issue is stale because it has been open for 30 days with no activity and it has not the 'status: confirmed' label or it is not in a milestone. Remove the 'status: stale' label or comment, or this will be closed in 5 days.

@rovilu
Copy link
Author

rovilu commented Nov 27, 2023

Up

Copy link

This issue is stale because it has been open for 30 days with no activity and it has not the 'status: confirmed' label or it is not in a milestone. Remove the 'status: stale' label or comment, or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2024
@frousselet frousselet reopened this Jan 8, 2024
@frousselet frousselet modified the milestones: 1.4.0, 1.4.1 Jan 8, 2024
@frousselet frousselet modified the milestones: 1.4.1, 1.4.2 May 30, 2024
@treywelsh
Copy link
Collaborator

I think it would be better to fix this at the same time we externalize the disk resource as it's not a critical bug
#525

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants