-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terraform plan/refresh error caused by existing data source state after schema change #30823
Comments
Hi @pst 👋 Thank you for raising this and apologies you ran into trouble here. Interestingly enough, this may be either an issue in the SDK or within Terraform CLI. Typically it should be expected that data sources are fully refreshed each run and therefore any prior state does not matter, however there is currently logic that in certain scenarios would trigger the prior state to actually be read. In that case, the current schema is mismatches that prior state and can generate the error seen here. Relevant log lines:
One workaround, although unfortunately a practitioner configuration breaking change, would be to drop the existing data source attribute and use a new one. Terraform CLI in that case should ignore the existing/old attribute state. Since it appears you may have been breaking existing configurations anyways, this might be an acceptable change for you. Thanks again for reporting this issue. |
I'm actually going to transfer this over to the Terraform CLI repository, so it becomes visible for one of the maintainers there to triage this from their perspective. 👍 |
Thanks for looking into this so quickly. The provider release is out and the issue was only discovered after the release. Renaming now would be a second breaking change for users. And the first one was already, from a regular user's perspective, unnecessary (since forced by a change in the SDK). For users it would certainly be best to fix the bug's root cause. Currently a workaround for users is to But with only single item Let's see what the Terraform core team says about this. |
Unfortunately I think the the The provider schema upgrade tests only covered the addition and removal of attributes, so this type of change was never verified. We can probably just ignore prior state in the case where the schema doesn't match as an interim solution, though I'm not sure if the lack of prior state in the plan output is going to surprise anyone or not. |
Thanks for getting this fixed so quickly! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
SDK version
I validated the bug exists with v2.13.0. However, the steps to reproduce below will use v.2.12.0, because I don't yet have a release with the updated minor version available.
Relevant provider source code
The change to the data source's schema linked below is causing this. The change was required to upgrade from v1 to v2, since the schema that was valid with v1 is not valid with v2 anymore.
https://github.com/kbst/terraform-provider-kustomization/pull/107/files#diff-a909667eef2686d43e97d8494c1a015e69b05673f68d2ba8c8f58ef8dec28fa4R235-R463
Terraform Configuration Files
Debug Output
https://gist.github.com/pst/e1155d1d05b96c1ce18acde32c1de5e6
Expected Behavior
Terraform plan
Actual Behavior
Steps to Reproduce
export KUBECONFIG_PATH=~/.kube/config
(kind, minikube, k3d) anything is fineterrraform init
terraform apply --auto-approve
0.7.2
to0.8.0
by commenting/uncommentingtarget
to be a block as required by the new schematerraform init --upgrade
terraform plan
References
kbst/terraform-provider-kustomization#169
The text was updated successfully, but these errors were encountered: