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

panic: interface conversion: interface {} is nil, not map[string]interface {} for HDInsight Kafka #12172

Closed
Andy-Gong opened this issue Jun 11, 2021 · 6 comments

Comments

@Andy-Gong
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.12.28
azurerm provider "~> 2.0"

Affected Resource(s)

  • azurerm_hdinsight_kafka_cluster

Terraform Configuration Files

resource "azurerm_hdinsight_kafka_cluster" "hdinsight_kafka_cluster" {
  lifecycle {
    ignore_changes = [
      gateway.0.password,
      roles.0.head_node.0.password,
      roles.0.worker_node.0.password,
      roles.0.zookeeper_node.0.password
    ]
  }

  name                = "stg-hdinsight-kafka-cluster"
  resource_group_name = var.resource_group_name
  location            = var.location
  cluster_version     = "4.0"
  tier                = "standard"

  component_version {
  }

storage_account {
    storage_container_id = xxx
    storage_account_key  = xxx
    is_default           = true
  }

  gateway {
    enabled  = true
    username = "xxx"
    password = azurerm_key_vault_secret.xxx.value
  }

  roles {
    head_node {
      vm_size            = "Standard_D3_V2"
      username           = "sshuser"
      password           = xxx
      subnet_id          = xxx
      virtual_network_id = xxx
    }

    worker_node {
      vm_size                  = "Standard_D3_V2"
      username                 = "sshuser"
      password                 = xxx
      number_of_disks_per_node = 2
      target_instance_count    = 3
      subnet_id                = xxx
      virtual_network_id       = xxx
    }

    zookeeper_node {
      vm_size            = "Standard_D3_V2"
      username           = "sshuser"
      password           = xxx
      subnet_id          = xxx
      virtual_network_id = xxx
    }
  }
  tags = local.common_tags
}

Debug Output

Panic Output

�Terraform v0.12.28
Initializing plugins and modules...
2021/06/09 10:57:57 [DEBUG] Using modified User-Agent: Terraform/0.12.28 TFE/v202103-3
random_password.secret: Creating...
random_password.secret: Creation complete after 0s [id=none]
azurerm_key_vault_secret.xxx_kafka_new_secret: Creating...
azurerm_key_vault_secret.xxx_kafka_new_secret: Creation complete after 2s [id=https://xxx/secrets/xxx-client-secret/478bb87e87af4f10b1a021859e63e65a]
azurerm_hdinsight_kafka_cluster.xxx-kafka-new: Creating...

Error: rpc error: code = Unavailable desc = transport is closing


panic: interface conversion: interface {} is nil, not map[string]interface {}
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: goroutine 342 [running]:
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hdinsight.expandHDInsightKafkaComponentVersion(...)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hdinsight/hdinsight_kafka_cluster_resource.go:379
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hdinsight.resourceHDInsightKafkaClusterCreate(0xc0002ff960, 0x5199800, 0xc0002c8900, 0x0, 0x0)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hdinsight/hdinsight_kafka_cluster_resource.go:184 +0x239f
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000dfac60, 0xc0019c2320, 0xc0019b1d80, 0x5199800, 0xc0002c8900, 0x51c6d01, 0xc001984fa8, 0xc0019eb620)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:310 +0x375
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc001488100, 0xc0015e9a38, 0xc0019c2320, 0xc0019b1d80, 0xc0019852a0, 0xc0019c1bf0, 0x51c9560)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:294 +0x99
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc00000ea18, 0x602b530, 0xc0019be1e0, 0xc0002ff180, 0xc00000ea18, 0xc0019be1e0, 0xc0006b7ba0)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:885 +0x8a5
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x5670f20, 0xc00000ea18, 0x602b530, 0xc0019be1e0, 0xc000ca8fc0, 0x0, 0x602b530, 0xc0019be1e0, 0xc000664600, 0x103d)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3305 +0x214
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003fe540, 0x606e658, 0xc001f00300, 0xc0020fd500, 0xc0015c49f0, 0x92b16a0, 0x0, 0x0, 0x0)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1180 +0x52b
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: google.golang.org/grpc.(*Server).handleStream(0xc0003fe540, 0x606e658, 0xc001f00300, 0xc0020fd500, 0x0)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1503 +0xd0c
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc00037a100, 0xc0003fe540, 0x606e658, 0xc001f00300, 0xc0020fd500)
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:843 +0xab
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-06-09T10:58:05.747Z [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:841 +0x1fd
2021-06-09T10:58:05.752Z [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-06-09T10:58:05.752Z [DEBUG] plugin: plugin process exited: path=/terraform/azure/xxx/staging/.terraform/plugins/linux_amd64/terraform-provider-azurerm_v2.56.0_x5 pid=238 error="exit status 2"
2021/06/09 10:58:05 [DEBUG] azurerm_hdinsight_kafka_cluster.xxx-kafka-new: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2021/06/09 10:58:05 [TRACE] EvalMaybeTainted: azurerm_hdinsight_kafka_cluster.xxx encountered an error during creation, so it is now marked as tainted
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalWriteState
2021/06/09 10:58:05 [TRACE] EvalWriteState: removing state object for azurerm_hdinsight_kafka_cluster.xxx
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalApplyProvisioners
2021/06/09 10:58:05 [TRACE] EvalApplyProvisioners: azurerm_hdinsight_kafka_cluster.xxx has no state, so skipping provisioners
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2021/06/09 10:58:05 [TRACE] EvalMaybeTainted: azurerm_hdinsight_kafka_cluster.xxx encountered an error during creation, so it is now marked as tainted
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalWriteState
2021/06/09 10:58:05 [TRACE] EvalWriteState: removing state object for azurerm_hdinsight_kafka_cluster.xxx
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalIf
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalIf
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalWriteDiff
2021/06/09 10:58:05 [TRACE] <root>: eval: *terraform.EvalApplyPost
2021/06/09 10:58:05 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2021/06/09 10:58:05 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2021/06/09 10:58:05 [TRACE] [walkApply] Exiting eval tree: azurerm_hdinsight_kafka_cluster.xxx
2021/06/09 10:58:05 [TRACE] vertex "azurerm_hdinsight_kafka_cluster.xxx": visit complete
2021/06/09 10:58:05 [TRACE] dag/walk: upstream of "provider.azurerm (close)" errored, so skipping
2021/06/09 10:58:05 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2021/06/09 10:58:05 [TRACE] dag/walk: upstream of "root" errored, so skipping
2021-06-09T10:58:05.934Z [DEBUG] plugin: plugin exited



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Comment: Leave feedback or record a decision.
© 2021 HashiCorp, Inc.

v202103-3

Expected Behaviour

When component_version is an empty block, we should return the specific error message, not panic

Actual Behaviour

panic

Steps to Reproduce

  1. terraform apply with empty component_version

Proposal fix

Dive into the code, we'd better check that input[0] is nil or not and return a default value if it is nil.

Current code:

func expandHDInsightKafkaComponentVersion(input []interface{}) map[string]*string {
	vs := input[0].(map[string]interface{})
	return map[string]*string{
		"kafka": utils.String(vs["kafka"].(string)),
	}
}

Proposal code:

func expandHDInsightKafkaComponentVersion(input []interface{}) map[string]*string {
	if input[0] == nil {
		return map[string]*string{
			"kafka": utils.String(""),
		}
	}
	vs := input[0].(map[string]interface{})
	return map[string]*string{
		"kafka": utils.String(vs["kafka"].(string)),
	}
}

Important Factoids

Not a big impact, just add the component_version.kafka to fix this, but it introduces a lot of troubleshooting work to find the root cause.

References

  • #0000
@favoretti
Copy link
Collaborator

Hi, thank you for reporting this. Will you be creating a PR?

@Andy-Gong
Copy link
Contributor Author

Hi, @favoretti , sure, I can do this

@Andy-Gong
Copy link
Contributor Author

Hi, @favoretti

A PR for fix this, please help to review.
#12261

@katbyte katbyte added the bug label Jun 23, 2021
@katbyte katbyte added this to the v2.65.0 milestone Jun 24, 2021
@tombuildsstuff tombuildsstuff modified the milestones: v2.65.0, v2.66.0 Jun 25, 2021
@jackofallops
Copy link
Member

closed by #12261

@github-actions
Copy link

github-actions bot commented Jul 2, 2021

This functionality has been released in v2.66.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Aug 2, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants