Import TKC to Terraform fails with Error
search cancel

Import TKC to Terraform fails with Error

book

Article ID: 380726

calendar_today

Updated On:

Products

Tanzu Mission Control VMware Tanzu Mission Control vSphere with Tanzu VMware vSphere with Tanzu

Issue/Introduction

Import of TKC to TMC Terraform Plugin fails with error message: 

terraform import tanzu-mission-control_tanzu_kubernetes_cluster.tkgs_cluster <MANAGEMENT_CLUSTER>/<NAMESPACE_NAME>/<CLUSTER_NAME>

 

 


tanzu-mission-control_tanzu_kubernetes_cluster.tkgs_cluster: Importing from ID "################################"...
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ImportResourceState call. The plugin logs may contain more details.
╵


Stack trace from the terraform-name-of-clusterl_v1.4.5.exe plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 25 [running]:
github.com/vmware/terraform-name-of-cluster/internal/resources/tanzukubernetescluster.removeModelVariable({0x1704fe0?, 0xc000a91b30}, {0x1704fe0?, 0xc000b95fb0?})
        github.com/vmware/terraform-name-of-cluster/internal/resources/tanzukubernetescluster/helper.go:464 +0x2c8
github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/tanzukubernetescluster.removeModelVariable({0x1704fe0?, 0xc000a916b0}, {0x1704fe0?, 0xc000b95e90?})
   .
   .
   .

Error: The terraform-name-of-cluster_v1.4.5.exe 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.

==============================

 

 

 

Environment

 

  • This occurs on environments using vSphere with Tanzu 8.x and ClusterClass based Guest Clusters. Specifically when managed by Terraform provider for Tanzu Mission Control.
  • The problem will arise when upgrading Guest Clusters between versions v1.25.7+vmware.3-fips.1-tkg.1 and v1.29.x+vmware.2-fips.1-tkg.1
     

Cause

Terraform import fails for the cluster class spec. The osImageRef does not have any additionalProperties although see labels does and it has a name field nested within it:

spec:

labels:
  additionalProperties:
    type: string
  type: object
osImageRef:
  type: object
  x-kubernetes-preserve-unknown-fields: true


actual yaml for the cluster:

osImageRef:
     name: ob-##########-photon-3-amd64-vmi-k8s-v#.##.#---vmware.2-tkg.1-zshippable



This causes the TF import code to fail because it expects that additionalProperties field or properties to exist when there is a nested object like osImageRef

Resolution

This is fixed in release 1.4.6 Terraform provider