Skip to content
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

tfsdk: Support protocol version 5 and verify valid resource type in UpgradeResourceState RPC #263

Merged
merged 3 commits into from
Feb 22, 2022

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 17, 2022

Reference: #42
Closes #262
Reference: hashicorp/terraform-provider-corner#44

Terraform CLI version 0.12 through 0.14 support protocol version 5 and require the UpgradeResourceStateResponse type UpgradedState type Msgpack field. To support downgraded framework providers via terraform-plugin-mux tf6to5server, the RawState type JSON field cannot simply be passed through like the previous implementation. This change will parse the RawState and output it via the tfprotov6.NewDynamicValue() function, which will always set the Msgpack field.

Similar logic would have already been required as part of the larger effort to support resource versioning and upgrading resource state over time.

Passthrough of the same state of an invalid resource type should not have been previously allowed, since the provider did not implement the resource type. Regardless, Terraform CLI should not have reached this point since GetProviderSchema would not have returned the resource type anyways for other resource operations.

Verified via integration testing of terraform-plugin-mux tf6to5server, which previously returned a non-descript EOF error.

…pgradeResourceState RPC

Reference: #42
Reference: #262
Reference: hashicorp/terraform-provider-corner#44

Terraform CLI version 0.12 through 0.14 support protocol version 5 and require the `UpgradeResourceStateResponse` type `UpgradedState` type `Msgpack` field. To support downgraded framework providers via terraform-plugin-mux `tf6to5server`, the `RawState` type `JSON` field cannot simply be passed through like the previous implementation. This change will parse the `RawState` and output it via the `tfprotov6.NewDynamicValue()` function, which will always set the `Msgpack` field.

Similar logic would have already been required as part of the larger effort to support resource versioning and upgrading resource state over time.

Passthrough of the same state of an invalid resource type should not have been previously allowed, since the provider did not implement the resource type. Regardless, Terraform CLI should not have reached this point since `GetProviderSchema` would not have returned the resource type anyways for other resource operations.

Verified via integration testing of terraform-plugin-mux `tf6to5server`, which previously returned a non-descript `EOF` error.
@bflad bflad added the bug Something isn't working label Feb 17, 2022
@bflad bflad added this to the v0.6.0 milestone Feb 17, 2022
@bflad bflad requested a review from a team as a code owner February 17, 2022 17:17
bflad added a commit to hashicorp/terraform-provider-corner that referenced this pull request Feb 17, 2022
Copy link
Contributor

@detro detro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit, I don't fully follow this code (yet, hopefully!).
But the general idea (provide a controlled, programmatic way to support a provider-supported upgrade) makes perfect sense. And it plugs a "hole" where previously the behaviour was, essentially, undefined.

LGTM

@bflad bflad merged commit ce0064c into main Feb 22, 2022
@bflad bflad deleted the bflad-UpgradeResourceState-Msgpack branch February 22, 2022 13:47
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tfsdk: Send UpgradeResourceStateResponse.UpgradedState.Msgpack for Terraform 0.12-0.14 Compatibility
2 participants