gomorpheus / terraform-provider-morpheus

Terraform Morpheus provider
MIT License
17 stars 21 forks source link

Plugin Crashes on Windows Server 2019 and RHEL9 #294

Open RedRaikiri opened 1 month ago

RedRaikiri commented 1 month ago

Dear community, dear developers,

due to missing possibilities I am trying to run the provider from a Windows-Server-Instance. As an addition: it is an experiment from my point of view. I did a really basic setup and have no chance to apply any of my changes. Terraform init and plan went flawless.

Because the issue persits in Version 0.11.0 (started trying on version 0.9.8, continued on 0.10.0) I´m reporting the issue now. CPU Runs on 2,79GHz and the system has 16GB of RAM. A 64bits Version of Windows Server 2019 Version 1809 is running. OS-Build: 17763.6414. The instance is not allowed to connect to the internet. Downloaded the provider from another device or directly from the repo.

Due to offline requirement I followed this setup for the environment: https://somspeaks.com/terraform-offline-setup-and-initialization/

I am not reporting issues that often. If you have any questions I will try to answer as soon as possible.

Now the Error-Code:
morpheus_vsphere_instance.tf_example_vsphere_instance: Creating... 
╷ 
│ Error: Plugin did not respond
│
│   with morpheus_vsphere_instance.tf_example_vsphere_instance,
│   on main.tf line 50, in resource "morpheus_vsphere_instance" "tf_example_vsphere_instance":
│   50: resource "morpheus_vsphere_instance" "tf_example_vsphere_instance" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-morpheus_v0.11.0.exe plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x2c pc=0xaf359e]

goroutine 58 [running]:
github.com/gomorpheus/terraform-provider-morpheus/morpheus.resourceVsphereInstanceCreate({0xe62a40, 0xc073d10}, 0xc073cc0, {0xcdd8a0, 0xc318280})
        github.com/gomorpheus/terraform-provider-morpheus/morpheus/resource_vsphere_instance.go:307 +0x25e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc392850, {0xe629e0, 0xc685368}, 0xc073cc0, {0xcdd8a0, 0xc318280})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:806 +0x11d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc392850, {0xe629e0, 0xc685368}, 0xc528af0, 0xc073bd0, {0xcdd8a0, 0xc318280})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:937 +0xaa2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc2bce40, {0xe629e0, 0xc685320}, 0xc31ff20)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xf46
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc072690, {0xe629e0, 0xc685038}, 0xc178ec0)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:865 +0x424
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xca14e0, 0xc072690}, {0xe629e0, 0xc685038}, 0xc178e80, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x176
google.golang.org/grpc.(*Server).processUnaryRPC(0xc090780, {0xe629e0, 0xc685008}, {0xe6459c, 0xc252000}, 0xc0800a0, 0xc2f8b28, 0x1476ecc, 0x0)
        google.golang.org/grpc@v1.63.2/server.go:1369 +0xf89
google.golang.org/grpc.(*Server).handleStream(0xc090780, {0xe6459c, 0xc252000}, 0xc0800a0)
        google.golang.org/grpc@v1.63.2/server.go:1780 +0x1108
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.63.2/server.go:1019 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 36
        google.golang.org/grpc@v1.63.2/server.go:1030 +0x13f

Error: The terraform-provider-morpheus_v0.11.0.exe plugin crashed!

Code is pretty basic:

terraform {
  required_providers {
    morpheus = {
      source  = "gomorpheus/morpheus"
      version = "0.11.0"
    }
  }
}

provider "morpheus" {
  url          = var.morpheus_url
  #username = var.morpheus_username
  #password = var.morpheus_password
  access_token = var.morpheus_access_token
  #tenant_subdomain = "<censored>" -> not needed when using access_token
}

resource "morpheus_vsphere_instance" "tf_example_vsphere_instance" {
  name               = "terraformTest"
  description        = "terraform Test"
  cloud_id           = "<censored>" #data.morpheus_cloud.morpheus_vsphere.id
  group_id           = "<censored>" #data.morpheus_group.<censored>_group.id
  instance_type_id   = "<censored>" #data.morpheus_instance_type.RHEL_Server_<censored>.id
  instance_layout_id = "<censored>" #data.morpheus_instance_layout.RHEL9.id
  plan_id            = "<censored>" #data.morpheus_plan.vmware.id
  environment        = "<censored>"
  resource_pool_id   = "<censored>" #data.morpheus_resource_pool.ressourcePoolOne.id
  #labels = ["demo", "terraform"]

  interfaces {
    network_id = "<censored>" #data.morpheus_network.vmnetwork.id
  }

  #  tags {
  #    name = "tf"
  #  }

  evar {
    name   = "application"
    value  = "demo"
    export = true
    masked = true
  }
}

Hope this helps.

RedRaikiri commented 3 weeks ago

Update:

Tested the same code on a RHEL9 Machine. It seems like the issue is bigger than expected. The error on RHEL9:

╷
│ Error: Plugin did not respond
│
│   with morpheus_vsphere_instance.tf_example_vsphere_instance,
│   on main.tf line 50, in resource "morpheus_vsphere_instance" "tf_example_vsphere_instance":
│   50: resource "morpheus_vsphere_instance" "tf_example_vsphere_instance" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-morpheus_v0.11.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x2c pc=0x8a54880]

goroutine 52 [running]:
github.com/gomorpheus/terraform-provider-morpheus/morpheus.resourceVsphereInstanceCreate({0x8dbdb50, 0xa017860}, 0xa017810, {0x8c3db20, 0x9cc6b80})
        github.com/gomorpheus/terraform-provider-morpheus/morpheus/resource_vsphere_instance.go:307 +0x260
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x9f88930, {0x8dbdaf0, 0xa010648}, 0xa017810, {0x8c3db20, 0x9cc6b80})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:806 +0x11f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x9f88930, {0x8dbdaf0, 0xa010648}, 0x9fe2c40, 0xa017720, {0x8c3db20, 0x9cc6b80})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:937 +0xaa4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x9eaebb0, {0x8dbdaf0, 0xa010600}, 0xa02aa80)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xf48
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x9dfa6e0, {0x8dbdaf0, 0xa010318}, 0xa0188c0)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:865 +0x426
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x8c013e0, 0x9dfa6e0}, {0x8dbdaf0, 0xa010318}, 0xa018880, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x178
google.golang.org/grpc.(*Server).processUnaryRPC(0x9cce780, {0x8dbdaf0, 0xa0102e8}, {0x8dbf6bc, 0x9f06600}, 0xa03a0a0, 0x9ef88d0, 0x93c64ac, 0x0)
        google.golang.org/grpc@v1.63.2/server.go:1369 +0xf8b
google.golang.org/grpc.(*Server).handleStream(0x9cce780, {0x8dbf6bc, 0x9f06600}, 0xa03a0a0)
        google.golang.org/grpc@v1.63.2/server.go:1780 +0x110a
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.63.2/server.go:1019 +0xad
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 39
        google.golang.org/grpc@v1.63.2/server.go:1030 +0x141

Error: The terraform-provider-morpheus_v0.11.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.
RedRaikiri commented 3 weeks ago

Used the 386 provider at first. Issue is also present on the linux_amd64 provider version