IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
342 stars 673 forks source link

crashes in ibm_is_floating_ip #3783

Open powellquiring opened 2 years ago

powellquiring commented 2 years ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Running in schematics:

 2022/05/16 17:02:17 Terraform apply | panic: runtime error: invalid memory address or nil pointer dereference
 2022/05/16 17:02:17 Terraform apply | [signal SIGSEGV: segmentation violation code=0x1 addr=0xf8 pc=0x24ad6e1]
 2022/05/16 17:02:17 Terraform apply | 
 2022/05/16 17:02:17 Terraform apply | goroutine 131 [running]:
 2022/05/16 17:02:17 Terraform apply | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc.floatingIPCollectionFloatingIpTargetToMap(0x0, 0x0, 0x4, 0x280e020, 0xc001354f20)
 2022/05/16 17:02:17 Terraform apply |  github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc/resource_ibm_is_floating_ip.go:663 +0x81
 2022/05/16 17:02:17 Terraform apply | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc.fipGet(0xc000bd7c80, 0x2dd3e20, 0xc0004cf200, 0xc0015ea570, 0x29, 0x0, 0xc0009f1680)
 2022/05/16 17:02:17 Terraform apply |  github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc/resource_ibm_is_floating_ip.go:393 +0x425
 2022/05/16 17:02:17 Terraform apply | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc.resourceIBMISFloatingIPRead(0xc000bd7c80, 0x2dd3e20, 0xc0004cf200, 0xc001275170, 0x18)
 2022/05/16 17:02:17 Terraform apply |  github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc/resource_ibm_is_floating_ip.go:364 +0x85
 2022/05/16 17:02:17 Terraform apply | github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc.resourceIBMISFloatingIPCreate(0xc000bd7c80, 0x2dd3e20, 0xc0004cf200, 0x2, 0xffffffffffffffff)
 2022/05/16 17:02:17 Terraform apply |  github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/vpc/resource_ibm_is_floating_ip.go:298 +0xda
 2022/05/16 17:02:17 Terraform apply | github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0009e6fc0, 0x3311958, 0xc0013e73c0, 0xc000bd7c80, 0x2dd3e20, 0xc0004cf200, 0x0, 0x0, 0x0)
 2022/05/16 17:02:17 Terraform apply |  github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:329 +0x1ee
 2022/05/16 17:02:17 Terraform apply | github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0009e6fc0, 0x3311958, 0xc0013e73c0, 0xc000772a90, 0xc000bd7a80, 0x2dd3e20, 0xc0004cf200, 0x0, 0x0, 0x0, ...)
 2022/05/16 17:02:17 Terraform apply |  github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:467 +0x67b
 2022/05/16 17:02:17 Terraform apply | github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000dd58, 0x3311958, 0xc0013e73c0, 0xc000d81220, 0x2e03222, 0x12, 0x0)
 2022/05/16 17:02:17 Terraform apply |  github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:977 +0xacf
 2022/05/16 17:02:17 Terraform apply | github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00050e680, 0x3311a00, 0xc0013e73c0, 0xc000887500, 0x0, 0x0, 0x0)
 2022/05/16 17:02:17 Terraform apply |  github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:603 +0x465
 2022/05/16 17:02:17 Terraform apply | github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x2d059c0, 0xc00050e680, 0x3311a00, 0xc0011f1e90, 0xc000bcb680, 0x0, 0x3311a00, 0xc0011f1e90, 0xc000e78380, 0x319)
 2022/05/16 17:02:17 Terraform apply |  github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
 2022/05/16 17:02:17 Terraform apply | google.golang.org/grpc.(*Server).processUnaryRPC(0xc000188fc0, 0x332b9f8, 0xc0000a3980, 0xc001466000, 0xc000b535c0, 0x42be160, 0x0, 0x0, 0x0)
 2022/05/16 17:02:17 Terraform apply |  google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
 2022/05/16 17:02:17 Terraform apply | google.golang.org/grpc.(*Server).handleStream(0xc000188fc0, 0x332b9f8, 0xc0000a3980, 0xc001466000, 0x0)
 2022/05/16 17:02:17 Terraform apply |  google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
 2022/05/16 17:02:17 Terraform apply | google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000044ce0, 0xc000188fc0, 0x332b9f8, 0xc0000a3980, 0xc001466000)
 2022/05/16 17:02:17 Terraform apply |  google.golang.org/grpc@v1.32.0/server.go:859 +0xab
 2022/05/16 17:02:17 Terraform apply | created by google.golang.org/grpc.(*Server).serveStreams.func1
 2022/05/16 17:02:17 Terraform apply |  google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd
 2022/05/16 17:02:17 Terraform apply | 
 2022/05/16 17:02:17 Terraform apply | Error: The terraform-provider-ibm_v1.41.0 plugin crashed!
 2022/05/16 17:02:17 Terraform apply | 
 2022/05/16 17:02:17 Terraform apply | This is always indicative of a bug within the plugin. It would be immensely
 2022/05/16 17:02:17 Terraform apply | helpful if you could report the crash with the plugin's maintainers so that it
 2022/05/16 17:02:17 Terraform apply | can be fixed. The output above should help diagnose the issue.
powellquiring commented 2 years ago

Happened again, I think the instance the floating ip was connected to did not get created on the previous run.

powellquiring commented 2 years ago

I'm working around this problem, maybe that is contributing, let me look a little harder: https://github.com/IBM-Cloud/terraform-provider-ibm/issues/3740

powellquiring commented 2 years ago

I was able to reproduce with 1.41, fixed in 1.40

cd /tmp
git clone https://github.com/powellquiring/tfbugs
cd tfbugs/bug-vpc-fip-panic
cp template.local.env local.env
vi local.env; # edit it
terraform init
terraform apply
# panic

See the version.tf to make it work for older releases:

bug-vpc-fip-panic $ cat version.tf
terraform {
  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      #version = "< 1.41.0"
      version = "= 1.41.0"
    }
  }
  required_version = "= 1.1.9"
}
olc-olivier commented 2 years ago

I have a similar bug with my script. Just try to retrieve my floating IP existing.

data "ibm_is_floating_ip" "front_fip" {
  name = local.FLOATING_IP_FRONT_NAME
}

version.tf

terraform {terraform {
  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      version = "1.42.0"
    }
  }
  required_version = ">= 1.2.2"
}
  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      version = "1.42.0"
    }
  }
  required_version = ">= 1.2.2"
}

_Error: The terraform-provider-ibmv1.42.0 plugin crashed!

I have another problem linked to floating IP. I would like to associate my flooting IP existing to an "ibm_is_public_gateway" or "ibm_is_instance.primary_network_interface" But it doesn't work, even with v1.40

data "ibm_is_floating_ip" "gw_fip" {
  name = local.FLOATING_IP_GATEWAY_NAME
}

resource "ibm_is_public_gateway" "maintenance_gateway" {
  name           = "${local.VPC_ZONE_PREFIX}-gw"
  resource_group = data.ibm_resource_group.rg.id
  tags           = local.TAG
  vpc            = ibm_is_vpc.vpc.id
  zone           = var.zone1
-->  floating_ip =  data.ibm_is_floating_ip.gw_fip or floating_ip =  { "id"=data.ibm_is_floating_ip.gw_fip.id }
}

_Tag attribut missing error or existing floating IP don't be associate

and for second try

data "ibm_is_floating_ip" "front_fip" {
  name = local.FLOATING_IP_FRONT_NAME
}

resource "ibm_is_instance_network_interface" "front_nic" {
  instance          = ibm_is_instance.dm-front.id
  subnet            = ibm_is_subnet.front_subnet.id
  security_groups   = [ibm_is_security_group.z1_maintenance_sg.id, ibm_is_security_group.z1_front_sg.id]
  allow_ip_spoofing = false
  floating_ip       = data.ibm_is_floating_ip.front_fip.id
  name              = "eth1"
}

_Error I can create a new nic with existing floating ip but I can't replace with the primary_network_interface of my ibm_isinstance_