Open davidgiga1993 opened 1 year ago
Hi,
the core of the issue here is that the schema for compositions.apiextensions.crossplane.io
CRD is incomplete and uses x-kubernetes-preserve-unknown-fields
wildcards which allow for ambiguity in the schema. The provider is unable to establish an exact data type for the attributes that are affected by this as required by Terraform and errs on the side of caution because you could otherwise end up with a broken Terraform state later on as those values get updated.
We'll have a to look a bit deeper into this specific CRD to determine if any workarounds are possible. I'll update here as we find out more.
Ah I see, thanks a lot for analyzing the issue, would be cool if that would in the future. For now we just use octoploy for the crossplane xrd part.
Hey @alexsomesan, I'm running into possibly a related error.
I am using a CRD which has, in its latest version, set x-kubernetes-preserve-unknown-fields
. It was working before this.
The link to the CRD diff is here: https://github.com/argoproj/argo-cd/compare/v2.6.7...v2.8.2#diff-1f5eb01e71d24fec7b77c000aee8ac6cdeffce1403021bd72b1f891809645da0
(I apologize, you'll have to click "files changed" and then ctrl+f "application-crd.yaml" since deeplinking on github doesn't seem to work for this case.)
Notably there is this addition:
valuesObject:
description: ValuesObject specifies Helm values to be
passed to helm template, defined as a map. This takes
precedence over Values.
type: object
x-kubernetes-preserve-unknown-fields: true
Since the change (to sources.helm.valuesObject
), I'm getting:
│ Error: Failed to transform List value into Tuple of different length
│
│ with module.argo_app.kubernetes_manifest.raw[0],
│ on .terraform/modules/argo_app/main.tf line 172, in resource "kubernetes_manifest" "raw":
│ 172: resource "kubernetes_manifest" "raw" {
│
│ Error: %!s(<nil>)
│ ...at attribute:
│ spec.sources
The error happens at plan time.
My code is thus:
# locals
multiple_sources = [for source in var.services : {
repo_url = local.helm_repo_url
chart = source.source_chart
path = null
target_revision = source.source_chart_version
helm = {
release_name = source.name
values = source.helm_values
}
}]
sources_map = { for source in local.sources : source.helm.release_name => source }
# ...
# then inside kubernetes_manifest:
sources = [for source, config in local.sources_map : {
repoURL = config.repo_url
path = config.path
chart = config.chart
targetRevision = config.target_revision
helm = {
releaseName = config.helm.release_name
values = config.helm.values
#valuesObject would live here if I was setting it
}
}]
It seems like there is a similar issue with the provider on a different CR, so I'm wondering if these are all related to unknown fields.
Is there a clean way to make the provider ignore the problematic field(s)?
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Due to confidentiality of the project I can't provide the full debug output
Steps to Reproduce
terraform apply
Expected Behavior
Terraform should be able to import any valid k8s yml files
Actual Behavior
Terraform type error:
Important Factoids
Community Note