vmware / terraform-provider-tanzu-mission-control

Terraform provider to manage resources of Tanzu Mission Control
Mozilla Public License 2.0
38 stars 31 forks source link

tanzu-mission-control_tanzu_kubernetes_cluster fails with error "Couldn't read TKG cluster" #392

Open giovannibaratta opened 5 months ago

giovannibaratta commented 5 months ago

Describe the bug

While creating a tanzu-mission-control_tanzu_kubernetes_cluster in a clean environment, the request failed after several minutes with the error Couldn't read TKG cluster.

│ Error: Couldn't read TKG cluster.
│ Management Cluster Name: h2o-2-23532, Provisioner: tap, Cluster Name: tap-view: get request(v1alpha1/clusters/tap-view/kubeconfig?cli=TANZU_CLI&fullName.managementClusterName=h2o-2-23532&fullName.provisionerName=tap) failed with status : 401 Unauthorized, response: {"error":"could not extract auth context","code":16,"message":"could not extract auth context"}
│ 
│   with tanzu-mission-control_tanzu_kubernetes_cluster.tap_view,
│   on clusters-tap-view.tf line 18, in resource "tanzu-mission-control_tanzu_kubernetes_cluster" "tap_view":
│   18: resource "tanzu-mission-control_tanzu_kubernetes_cluster" "tap_view" {

Even if an error was returned, the cluster was available TMC leaving an unclean state. A second apply fails because the cluster already exist, a manual action is required (import in the state or delete the cluster in TMC).

Reproduction steps

Unknown

source code is available here https://github.com/giovannibaratta/vmware-tanzu-training/tree/main/terraform/stages/50-tmc

Expected behavior

The resource should be created successfully, or a second apply should not result in a conflict.

Additional context