nutanix / terraform-provider-nutanix

Terraform Nutanix Provider
https://www.terraform.io/docs/providers/nutanix/
Mozilla Public License 2.0
101 stars 112 forks source link

TF NTNX Provider Crashed #567

Closed levtech1 closed 1 year ago

levtech1 commented 1 year ago

Nutanix Cluster Information

Terraform Version

Your version of Terraform is out of date! The latest version is 1.4.0. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

resource "nutanix_ndb_database" "dbp" {

// name of database type
databasetype = "sqlserver_database"

// required name of db instance
name = "test-inst"
description = "add description"

// adding the profiles details
softwareprofileid = "{{ software_profile_id }}"
softwareprofileversionid =  "{{ software_profile_version_id }}"
computeprofileid =  "{{ compute_profile_id }}"
networkprofileid = "{{ network_profile_id }}"
dbparameterprofileid = "{{ db_parameter_profile_id }}"

// postgreSQL Info
postgresql_info{
    listener_port = "{{ listner_port }}"

    database_size= "{{ 200 }}"

    db_password =  "password"

    database_names= "testdb1"
}

// era cluster id
nxclusterid= data.nutanix_ndb_cluster.poc004.id

// ssh-key
sshpublickey= "{{ ssh-public-key }}"

// node for single instance
nodes{
    // name of dbserver vm 
    vmname= "test-era-vm1"

    // network profile id
    networkprofileid= "<network-profile-uuid>"
}

// time machine info 
timemachineinfo {
    name= "test-pg-inst"
    description="description of time machine"
    slaid= "{{ sla_id }}"

    // schedule info fields are optional.
    schedule {
        snapshottimeofday{
            hours= 16
            minutes= 0
            seconds= 0
        }
        continuousschedule{
            enabled=true
            logbackupinterval= 30
            snapshotsperday=1
        }
        weeklyschedule{
            enabled=true
            dayofweek= "WEDNESDAY"
        }
        monthlyschedule{
            enabled = true
            dayofmonth= "27"
        }
        quartelyschedule{
            enabled=true
            startmonth="JANUARY"
            dayofmonth= 27
        }
        yearlyschedule{
            enabled= false
            dayofmonth= 31
            month="DECEMBER"
        }
    }
}

}

---> lev.goronshtein@G5QM65D47Q MSSQL % terraform plan data.nutanix_ndb_cluster.poc004: Reading... ╷ │ Warning: Disabled Providers: foundation. Please provide required fields in provider configuration to enable them. Refer docs. │ │ with provider["registry.terraform.io/nutanix/nutanix"], │ on provider.tf line 10, in provider "nutanix": │ 10: provider "nutanix" { │ ╵ ╷ │ Error: Plugin did not respond │ │ with data.nutanix_ndb_cluster.poc004, │ on sql.tf line 1, in data "nutanix_ndb_cluster" "poc004": │ 1: data "nutanix_ndb_cluster" "poc004" { │ │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details. ╵

Stack trace from the terraform-provider-nutanix_v1.8.0 plugin:

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

goroutine 22 [running]: github.com/terraform-providers/terraform-provider-nutanix/nutanix.dataSourceNutanixEraClusterRead({0x101b01668, 0x140004fe720}, 0x140000f6780, {0x10198a4a0, 0x140010d50e0}) github.com/terraform-providers/terraform-provider-nutanix/nutanix/data_source_nutanix_ndb_cluster.go:280 +0x1574 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).read(0x14000568b60, {0x101b015f8, 0x1400011a5c0}, 0x140000f6780, {0x10198a4a0, 0x140010d50e0}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:358 +0x118 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).ReadDataApply(0x14000568b60, {0x101b015f8, 0x1400011a5c0}, 0x140000f6680, {0x10198a4a0, 0x140010d50e0}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:569 +0xf4 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ReadDataSource(0x14000114030, {0x101b015f8, 0x1400011a5c0}, 0x14000b8c400) github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:1133 +0x434 github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ReadDataSource(0x14000290980, {0x101b016a0, 0x14000b821e0}, 0x14000ad80a0) github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:478 +0x37c github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x101aab460, 0x14000290980}, {0x101b016a0, 0x14000b821e0}, 0x140004fe180, 0x0) github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:416 +0x1c0 google.golang.org/grpc.(Server).processUnaryRPC(0x1400020ce00, {0x101b0e4f0, 0x140003c6300}, 0x14000d2a000, 0x1400039bc20, 0x102068170, 0x0) google.golang.org/grpc@v1.32.0/server.go:1194 +0xc38 google.golang.org/grpc.(Server).handleStream(0x1400020ce00, {0x101b0e4f0, 0x140003c6300}, 0x14000d2a000, 0x0) google.golang.org/grpc@v1.32.0/server.go:1517 +0xa34 google.golang.org/grpc.(Server).serveStreams.func1.2(0x14000034de0, 0x1400020ce00, {0x101b0e4f0, 0x140003c6300}, 0x14000d2a000) google.golang.org/grpc@v1.32.0/server.go:859 +0x94 created by google.golang.org/grpc.(Server).serveStreams.func1 google.golang.org/grpc@v1.32.0/server.go:857 +0x1f0

Error: The terraform-provider-nutanix_v1.8.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.

abhimutant commented 1 year ago

Hi @levtech1, Seems you are providing wrong NDB cluster id. Please get the correct cluster id. You can use below code as well.

data "nutanix_ndb_clusters" "test1" {}

data "nutanix_ndb_cluster" "test" {
    cluster_id = data.nutanix_ndb_clusters.test1.clusters[0].id
}
levtech1 commented 1 year ago

Thank you but even if i provide the wrong ID should it crash the plug in?

Abhishekism9450 commented 1 year ago

I agree. It shouldn't crash the plugin. Moreover, NDB API for cluster doesn't return any error. So the validation for error passes. I will recheck and improve the code to avoid plugin crash in future.

abhimutant commented 1 year ago

PR: #571

abhimutant commented 1 year ago

Fix is available in latest v1.8.1 release.