streamnative / terraform-provider-pulsar

Terraform provider for managing Apache Pulsar entities
Apache License 2.0
43 stars 35 forks source link

[bug][replication]: when destroying resources with replication configs, provider should cleanup the replication config first #81

Open ericsyh opened 1 year ago

ericsyh commented 1 year ago

Community Note

Terraform Version

v1.0.3

Affected Resource(s)

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

provider "pulsar"{
    alias = "us-east"
    web_service_url = ""
    issuer_url = ""
    audience = ""
    key_file_path = ""
}

resource "pulsar_cluster" "us-west-cluster" {
  provider = pulsar.us-east
  cluster = "us-west"

  cluster_data {
    web_service_url    = "<web_service_url>"
    broker_service_url = "<broker_service_url>"
  }
}

resource "pulsar_tenant" "us-east-geo-tenant" {
  provider = pulsar.us-east
  tenant = "geo-tenant"
  allowed_clusters = [
    "us-east",
    pulsar_cluster.us-west-cluster.cluster
  ]
}

resource "pulsar_namespace" "us-east-geo-namespace" {
  provider  = pulsar.us-east
  tenant    = pulsar_tenant.us-east-geo-tenant.tenant
  namespace = "geo-namespace"

  namespace_config {
    replication_clusters = [
      "us-east",
      pulsar_cluster.us-west-cluster.cluster
    ]
  }
}

Debug Output

Panic Output

Expected Behavior

Destroy successfully.

Actual Behavior

pulsar_namespace.us-east-geo-namespace: Destroying... [id=geo-tenant/geo-namespace]
pulsar_namespace.us-west-geo-namespace: Destroying... [id=geo-tenant/geo-namespace]
β•·
β”‚ Error: ERROR_DELETE_NAMESPACE: code: 412 reason: Cannot delete the global namespace geo-tenant/geo-namespace. There are still more than one replication clusters configured.
β”‚
β”‚
β•΅
β•·
β”‚ Error: ERROR_DELETE_NAMESPACE: code: 412 reason: Cannot delete the global namespace geo-tenant/geo-namespace. There are still more than one replication clusters configured.
β”‚
β”‚
β•΅

Steps to Reproduce

  1. terraform apply to create resources
  2. terrafrom destroy to cleanup resources

Important Factoids

References