terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

`kubernetes_manifest` errors with `x-kubernetes-preserve-unknown-fields` CRD of ArgoCD Application

Open jcogilvie opened this issue 1 year ago • 2 comments

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.6
Kubernetes provider version: 2.24.0
Kubernetes version: 1.27

Affected Resource(s)

  • kubernetes_manifest

Terraform Configuration Files

Please see https://github.com/argoproj/argo-cd/issues/16115 for config and repro case

Debug Output

Please see https://github.com/argoproj/argo-cd/issues/16115 for output

Steps to Reproduce

  1. terraform apply the indicated manifest against argocd's Application CRD from v2.8+, in which it adds the x-kubernetes-preserve-unknown-fields annotation to a new field called valuesObject

Expected Behavior

It would be ideal if the provider could detect that there is not and never has been a value provided for the unknown field in my CR instance, so it can simply ignore the type change, but if it can't, then I would at least expect that the resource is deleted and recreated as indicated in https://github.com/hashicorp/terraform-provider-kubernetes/issues/1928#issuecomment-1341043424

Actual Behavior

Apply error

Important Factoids

EKS 1.27

References

  • https://github.com/hashicorp/terraform-provider-kubernetes/issues/2123
  • maybe https://github.com/hashicorp/terraform-provider-kubernetes/issues/1930

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

jcogilvie avatar Dec 20 '23 21:12 jcogilvie

@jcogilvie Could we get a glimpse of the actual output of Terraform when the apply returns an error?

alexsomesan avatar Jan 18 '24 14:01 alexsomesan

My mistake; it errors on plan. Here's the error from a plan (which I can't presently get past to test the apply):

╷
│ Error: Failed to transform List value into Tuple of different length
│ 
│   with module.this_app[0].kubernetes_manifest.raw[0],
│   on .terraform/modules/this_app/main.tf line 172, in resource "kubernetes_manifest" "raw":
│  172: resource "kubernetes_manifest" "raw" {
│ 
│ Error: %!s(<nil>)
│ ...at attribute:
│ spec.sources
╵
╷
│ Error: Failed to transform Object element into Object element type
│ 
│   with module.this_app[0].kubernetes_manifest.raw[0],
│   on .terraform/modules/this_app/main.tf line 172, in resource "kubernetes_manifest" "raw":
│  172: resource "kubernetes_manifest" "raw" {
│ 
│ Error (see above) at attribute:
│ spec.sources
╵
╷
│ Error: Failed to transform Object element into Object element type
│ 
│   with module.this_app[0].kubernetes_manifest.raw[0],
│   on .terraform/modules/this_app/main.tf line 172, in resource "kubernetes_manifest" "raw":
│  172: resource "kubernetes_manifest" "raw" {
│ 
│ Error (see above) at attribute:
│ spec
╵

more output in gist

jcogilvie avatar Jan 25 '24 19:01 jcogilvie