rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
253 stars 216 forks source link

[BUG] Namespace import on unavailable cluster: Unknown schema type [namespace] #1345

Open jansobczak opened 2 months ago

jansobczak commented 2 months ago

Rancher Server Setup

Information about the Cluster

User Information

Provider Information

Describe the bug

When trying to import existing namespace from cluster that is unreachable but already had been added to the Rancher the following error occured


➜  rancher-dareth git:(K8S-2791/add-provider) ✗ TF_LOG=DEBUG op run -- terraform import 'module.julien-prod-noc.rancher2_namespace.rancher-project-namespace["prod-noc"]' c-m-z2w6zsvt:p-5l9n2.prod-noc
2024-05-02T15:21:12.732+0200 [INFO]  Terraform version: 1.8.2
2024-05-02T15:21:15.020+0200 [DEBUG] provider.terraform-provider-rancher2_v3.0.2: 2024/05/02 15:21:15 Time to get req:  123  ms
2024-05-02T15:21:15.271+0200 [ERROR] vertex "module.julien-prod-noc.rancher2_namespace.rancher-project-namespace[\"prod-noc\"] (import id \"c-m-z2w6zsvt:p-5l9n2.prod-noc\")" error: Unknown schema type [namespace]
2024-05-02T15:21:15.271+0200 [ERROR] vertex "module.julien-prod-noc.rancher2_namespace.rancher-project-namespace (expand)" error: Unknown schema type [namespace]
╷
│ Error: Unknown schema type [namespace]
│ 
│ 
╵

To Reproduce

  1. Add existing k8s cluster to rancher
  2. create NS in rancher GUI
  3. break communication between rancher and cattle-agent on k8s cluster
  4. try to import created namespace (with resource https://registry.terraform.io/providers/rancher/rancher2/3.2.0/docs/resources/namespace)
    resource "rancher2_namespace" "rancher-project-namespace" {
    name        = each.key
    project_id  = rancher2_project.rancher-project[0].id
    description = "${each.key} namespace"
    depends_on  = [rancher2_project.rancher-project]
    wait_for_cluster = true
    }

Expected Result

The wait_for_cluster argument should be taken into account