Mongey / terraform-provider-kafka

Terraform provider for managing Apache Kafka Topics + ACLs
MIT License
517 stars 129 forks source link

Module crash using kafka-topic resources on refresh state #222

Open Rodrigonavarro23 opened 2 years ago

Rodrigonavarro23 commented 2 years ago

Module crash when trying to refresh state from topic resources.

Summary of my provider config:

terraform {
  required_providers {
    consul = {
      source  = "hashicorp/consul"
      version = "2.12.0"
    }

    kafka = {
      source  = "Mongey/kafka"
      version = "0.4.2"
    }
  }

  backend "consul" {}
}

provider "kafka" {
  bootstrap_servers = [var.bootstrap_servers]
  sasl_username     = var.sasl_username
  sasl_password     = var.sasl_password
  sasl_mechanism    = "plain"
  tls_enabled       = true
  timeout           = 300
}
...

Summary of topics tf file:

resource "kafka_topic" "cenco-arcus-tasks-create" {
  name               = "cenco.arcus.tasks.create"
  replication_factor = var.default_replication_factor
  partitions         = var.default_partitions
  config = {
    "cleanup.policy" = "delete"
    "retention.ms"   = "86400000"
  }
}

resource "kafka_topic" "cenco-arcus-tasks-update" {
  name               = "cenco.arcus.tasks.update"
  replication_factor = var.default_replication_factor
  partitions         = var.default_partitions
  config = {
    "cleanup.policy" = "delete"
    "retention.ms"   = "86400000"
  }
}
...

This is a summary of the error:

time="2022-01-27T14:36:59Z" level=info msg="Drone Terraform Plugin Version" Revision= 
$ terraform version
Terraform v1.0.4
on linux_amd64

Initializing the backend...

Successfully configured the backend "consul"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding hashicorp/consul versions matching "2.12.0"...
- Finding mongey/kafka versions matching "0.4.2"...
- Installing hashicorp/consul v2.12.0...
- Installed hashicorp/consul v2.12.0 (signed by HashiCorp)
- Installing mongey/kafka v0.4.2...
- Installed mongey/kafka v0.4.2 (self-signed, key ID 5C886ACC44EB17C0)

Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
$ terraform get
$ terraform plan -out=plan.tfout
kafka_topic.cenco-arcus-tasks-planograma-completed: Refreshing state... [id=cenco.arcus.tasks.planograma.completed]
kafka_topic.cenco-arcus-tasks-foundratealerts-completed: Refreshing state... [id=cenco.arcus.tasks.foundratealerts.completed]
kafka_topic.cenco-arcus-tasks-update: Refreshing state... [id=cenco.arcus.tasks.update]
...

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
   update in-place

Terraform will perform the following actions:

kafka_topic.cenco-arcus-tasks-create will be updated in-place
   resource "kafka_topic" "cenco-arcus-tasks-create" {
       config             = {
          "cleanup.policy" = "delete"
          "retention.ms"   = "86400000"
        }
        id                 = "cenco.arcus.tasks.create"
        name               = "cenco.arcus.tasks.create"
        (2 unchanged attributes hidden)
    }

kafka_topic.cenco-arcus-tasks-forecastalerts-completed will be updated in-place
   resource "kafka_topic" "cenco-arcus-tasks-forecastalerts-completed" {
       config             = {
          "cleanup.policy" = "delete"
          "retention.ms"   = "86400000"
        }
        id                 = "cenco.arcus.tasks.forecastalerts.completed"
        name               = "cenco.arcus.tasks.forecastalerts.completed"
        (2 unchanged attributes hidden)
    }
...
Plan: 0 to add, 17 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan.tfout

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfout"
$ terraform apply plan.tfout
kafka_topic.cenco-arcus-tasks-recepmer-completed: Modifying... [id=cenco.arcus.tasks.recepmer.completed]
kafka_topic.cenco-arcus-tasks-openclosestore-updated: Modifying... [id=cenco.arcus.tasks.openclosestore.updated]
kafka_topic.cenco-arcus-tasks-planograma-received: Modifying... [id=cenco.arcus.tasks.planograma.received]
...

Plugin did not respond

  with kafka_topic.cenco-arcus-tasks-create,
  on topics.tf line 1, in resource "kafka_topic" "cenco-arcus-tasks-create":
   1: resource "kafka_topic" "cenco-arcus-tasks-create" {

The plugin encountered an error, and failed to respond to the
plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
contain more details.

Request cancelled

  with kafka_topic.cenco-arcus-tasks-update,
  on topics.tf line 11, in resource "kafka_topic" "cenco-arcus-tasks-update":
  11: resource "kafka_topic" "cenco-arcus-tasks-update" {

The plugin.(*GRPCProvider).UpgradeResourceState request was cancelled.

Plugin did not respond

  with kafka_topic.cenco-arcus-tasks-recepmer-received,
  on topics.tf line 21, in resource "kafka_topic" "cenco-arcus-tasks-recepmer-received":
  21: resource "kafka_topic" "cenco-arcus-tasks-recepmer-received" {

The plugin encountered an error, and failed to respond to the
plugin.(*GRPCProvider).UpgradeResourceState call. The plugin logs may
contain more details.

Plugin did not respond

  with kafka_topic.cenco-arcus-tasks-recepmer-report,
  on topics.tf line 31, in resource "kafka_topic" "cenco-arcus-tasks-recepmer-report":
  31: resource "kafka_topic" "cenco-arcus-tasks-recepmer-report" {

The plugin encountered an error, and failed to respond to the
plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
contain more details.

...

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-kafka_v0.4.2 plugin:

panic: Invalid diagnostic: empty summary. This is always a bug in the provider implementation

goroutine 115 [running]:
github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugin/convert.DiagsToProto(0xc0005b8480, 0x1, 0x1, 0xc00042ef00, 0x18, 0x18)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/internal/plugin/convert/diagnostics.go:72 +0x35c
github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugin/convert.AppendProtoDiag(0x0, 0x0, 0x0, 0xd53f00, 0xc00042ef00, 0xe2c9c0, 0xc000484930, 0xc0006185b0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/internal/plugin/convert/diagnostics.go:25 +0x99
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000c0f0, 0x10263f8, 0xc00045ac40, 0xc0003bf6d0, 0xe7ab54, 0x12, 0x0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/grpc_provider.go:978 +0xb3b
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00008a280, 0x10264a0, 0xc00045ac40, 0xc0004545b0, 0x0, 0x0, 0x0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:603 +0x465
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0xe32080, 0xc00008a280, 0x10264a0, 0xc000449d70, 0xc00046c3c0, 0x0, 0x10264a0, 0xc000449d70, 0xc000434c00, 0x1ea)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000a4540, 0x102f838, 0xc00012fc80, 0xc000500600, 0xc000089170, 0x15109c0, 0x0, 0x0, 0x0)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.34.0/server.go:1210 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0000a4540, 0x102f838, 0xc00012fc80, 0xc000500600, 0x0)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.34.0/server.go:1533 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000320b40, 0xc0000a4540, 0x102f838, 0xc00012fc80, 0xc000500600)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.34.0/server.go:871 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.34.0/server.go:869 +0x1fd

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

time="2022-01-27T14:37:07Z" level=fatal msg="Failed to execute a command" error="exit status 1" 
Rodrigonavarro23 commented 2 years ago

It is a problem with ACL, when you use a key without allowing ALTER_CONFIG and DESCRIBE_CONFIG to crash without an explicit error. Should display an error related to permissions.