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

[BUG] Plugin crash when adding "SLAVE" nameserver #38

Open
4 tasks done
JanKoppe opened this issue Sep 17, 2024 · 1 comment
Open
4 tasks done

[BUG] Plugin crash when adding "SLAVE" nameserver #38

JanKoppe opened this issue Sep 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JanKoppe
Copy link

Checklist

  • I have used the latest version of terraform (if not please provide a version number).
  • I have used the latest version of this terraform provider (if not please provide a version number).
  • I have provided a sample .tf configuration under "Additional context".
  • I have answered the following question: Is this issue reproducible in OT&E or only applies to live?

Describe the bug
When trying to setup a "SLAVE" type nameserver, the plugin crashes. This crash is reproducible on both live and OT&E.

The nameserver entry at INWX is actually being created, though.

The Log shows the following stack trace:

inwx_nameserver.primary: Creating...
╷
│ Error: Plugin did not respond
│
│   with inwx_nameserver.primary,
│   on main.tf line 80, in resource "inwx_nameserver" "primary":
│   80: resource "inwx_nameserver" "primary" {
│
│ 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-inwx_v1.4.2 plugin:

panic: interface conversion: interface {} is nil, not []interface {}

goroutine 98 [running]:
github.com/inwx/terraform-provider-inwx/inwx/internal/resource.resourceNameserverRecordRead({0xd14088, 0xc0001d6a10}, 0xc000507700, {0xb63320?, 0xc0004a6870})
	github.com/inwx/terraform-provider-inwx/inwx/internal/resource/resource_nameserver_record.go:263 +0xd74
github.com/inwx/terraform-provider-inwx/inwx/internal/resource.resourceNameserverCreate({0xd14088, 0xc0001d6a10}, 0xb1a5e0?, {0xb63320?, 0xc0004a6870?})
	github.com/inwx/terraform-provider-inwx/inwx/internal/resource/resource_nameserver.go:246 +0xb6b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc000166c40, {0xd13fe0, 0xc00052f470}, 0xd?, {0xb63320, 0xc0004a6870})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/resource.go:708 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000166c40, {0xd13fe0, 0xc00052f470}, 0xc000552680, 0xc000507580, {0xb63320, 0xc0004a6870})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/resource.go:838 +0x95a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000365aa0, {0xd14018?, 0xc0004a6b40?}, 0xc0004a6be0)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/grpc_provider.go:1021 +0xdbc
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0002306e0, {0xd13fe0?, 0xc00052ec30?}, 0xc0001d6150)
	github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/tf5server/server.go:812 +0x50b
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xbc9720?, 0xc0002306e0}, {0xd13fe0, 0xc00052ec30}, 0xc00060c4e0, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002b48c0, {0xd17d10, 0xc0003871e0}, 0xc0005326c0, 0xc0002e9ef0, 0x11d6760, 0x0)
	google.golang.org/grpc@v1.45.0/server.go:1282 +0xcd5
google.golang.org/grpc.(*Server).handleStream(0xc0002b48c0, {0xd17d10, 0xc0003871e0}, 0xc0005326c0, 0x0)
	google.golang.org/grpc@v1.45.0/server.go:1619 +0x9e7
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.45.0/server.go:921 +0x8d
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 26
	google.golang.org/grpc@v1.45.0/server.go:919 +0x246

Error: The terraform-provider-inwx_v1.4.2 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.

To Reproduce
Run the example Terraform configuration provided.

Expected behavior
The DNS zone should be correctly created as a secondary on the INWX nameservers, with the provided configuration on the Terraform resource. The plugin should not crash.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

Sample .tf configuration:

terraform {
  required_providers {
    inwx = {
      source = "inwx/inwx"
      version = ">= 1.0.0"
    }
  }
}

provider "inwx" {
  api_url = var.api_url
  tan = var.tan
  username = var.username
}

resource "inwx_nameserver" "primary" {
  domain = "test.example"
  type = "SLAVE"
  nameservers = ["ns.inwx.de"]
  master_ip = "192.0.2.1" # RFC5737 example IP
}
@JanKoppe JanKoppe added the bug Something isn't working label Sep 17, 2024
@JanKoppe
Copy link
Author

My initial look at this shows that https://github.com/inwx/terraform-provider-inwx/blob/main/inwx/internal/resource/resource_nameserver.go#L246 is trying to immediately read the NS records after creating the zone.

As this is a secondary zone which first needs to be filled with Information via AXFR, those records are most likely not available at the point where the code expects to be able to read back the NS records.

It would be good if the possible solution for this issue does not try to read the NS records for zones of type "SLAVE". If it would wait for those records to be available after an AXFR, you can run into issues where the actual creation of the primary zone and subsequent AXFR/NOTIFY needs to happen before the creation of the INWX resource. This introduces some inflexibility in usage. It's not a huge deal and can be worked around probably, but I think for some setups this might allow for a less complex resource ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant