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

Add helper for upgrading a tfprotov5 server to a tfprotov6 server transparently. #33

Closed
paddycarver opened this issue Apr 23, 2021 · 6 comments · Fixed by #42
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@paddycarver
Copy link
Contributor

terraform-plugin-go-contrib version

v0.1.0-dev

Use cases

We need a way to mux between terraform-plugin-sdk (v5) and terraform-plugin-framework (likely v6) and any providers built on terraform-plugin-go (v5 or v6). These projects are all going to use one of these two versions of the protocol, and we're going to want to be able to use mux with them, but that requires them to be on the same protocol version.

Attempted solutions

N/A

Proposal

Protocol version 5 is forward-compatible with protocol version 6--all its features exist and there's a direct 1:1 mapping for them. Because of this, it's possible for any protocol version 5 server to be transparently upgraded into a protocol version 6 server without any loss of fidelity or assumptions made on the part of the converter.

I'm proposing we add a tfprotov5tov6 package to this module which performs this upgrade between servers, converting a v5 server into a v6 server, allowing users to continue to use mux across the SDK, the framework, and plugin-go by calling a simple helper function.

References

N/A

@paddycarver paddycarver self-assigned this Apr 23, 2021
@paddycarver
Copy link
Contributor Author

So @bflad and I talked about this at some length, and decided we wanted to do two separate helpers:

  1. A helper to upgrade from v5 to v6, which will always work, but only works with Terraform 1.0+
  2. A helper to downgrade from v6 to v5, which will only work if nested attributes aren't used. Either an error should be returned or the provider should panic if nested attributes are found in the schema.

On further deliberation, we feel this probably shouldn't live in a contrib repository like this, where it's less likely to be discovered (given the relative frequency with which we expect it to be needed over the next year or two) and should probably live in terraform-plugin-mux, or maybe terraform-plugin-go directly.

The danger of including it in terraform-plugin-go directly is that if we ever want to change the API, it's going to be a breaking change for ~the entire ecosystem, which isn't great. But making it available there would make it easier to "upgrade" or "downgrade" providers built on terraform-plugin-go without having to go through muxing.

We can probably make that decision later. For now, I'm going to move the issue to plugin-mux, with the understanding that it could end up getting transferred to plugin-go later if it's decided that's a better place for it to live.

@paddycarver paddycarver transferred this issue from hashicorp/terraform-plugin-go-contrib Dec 23, 2021
@bflad bflad added the enhancement New feature or request label Dec 23, 2021
@bflad bflad added this to the v0.5.0 milestone Jan 6, 2022
@bflad bflad self-assigned this Jan 6, 2022
bflad added a commit that referenced this issue Jan 12, 2022
Reference: #19
Reference: #33

In the near future, this project will be implementing multiple packages which will be reliant on shared logging details. Refactoring this code now will prevent duplication when those packages get created.

This logging package structure is similar to what is being implemented in terraform-plugin-go, not only for code consistency, but in the event that portions or all of this project is subsumed into that project.
bflad added a commit that referenced this issue Jan 13, 2022
Reference: #19
Reference: #33

In the near future, this project will be implementing multiple packages which will be reliant on shared logging details. Refactoring this code now will prevent duplication when those packages get created.

This logging package structure is similar to what is being implemented in terraform-plugin-go, not only for code consistency, but in the event that portions or all of this project is subsumed into that project.
@bflad
Copy link
Contributor

bflad commented Jan 18, 2022

Once #37 and #39 are merged in some fashion, we'll have tf5testserver and tf6testserver implementations which should make testing these converters much easier without further duplicating test code.

@bflad
Copy link
Contributor

bflad commented Jan 18, 2022

A real blocking detail about muxing sdk/v2 and framework — protocol version 5 has a magic LegacyTypeSystem flag that sdk/v2 sets during ApplyResourceChange and PlanResourceChange to signal to CLI that the SDK doesn’t understand null values, ultimately turning off some consistency checks and only adding warning logs about the problem. Protocol version 6 does not include this flag. This means we are currently limited to muxing sdk/v2 and framework only in protocol version 5, otherwise really unexpected things could happen. Providers would need to fully convert everything over to framework before being able to shed sdk/v2 and upgrade to protocol version 6 with its new features.

If that’s an issue, we’ll need to immediately get a protocol update into Terraform CLI to carry forward that flag in version 6 of the protocol so sdk/v2 resources could still toggle that behavior when upgraded to protocol version 6 and muxed. It would be a weird situation though because we’d have to say framework+sdk/v2 mux support on protocol version 6 would only be available on Terraform CLI 1.1+ unless there’s a backport to 1.0.

@bflad
Copy link
Contributor

bflad commented Jan 19, 2022

Proposed addition of LegacyTypeSystem handling in protocol version 6:

Issue: hashicorp/terraform#30373
Pull Request: hashicorp/terraform#30375

@bflad
Copy link
Contributor

bflad commented Jan 20, 2022

terraform-plugin-go v0.7.0 contains the protocol addition and has been released. Will poke dependabot and update the dependency before continuing with this.

bflad added a commit that referenced this issue Jan 20, 2022
Reference: #33

These packages handle upgrading and downgrading protocol specific Go types. The functionality will be implemented by upgrade and downgrade servers.
bflad added a commit that referenced this issue Feb 2, 2022
Reference: #33

These packages handle upgrading and downgrading protocol servers. This enables additional provider combinations, such as terraform-plugin-sdk/v2 and terraform-plugin-framework.
@bflad bflad closed this as completed in #42 Feb 7, 2022
bflad added a commit that referenced this issue Feb 7, 2022
Reference: #33

These packages handle upgrading and downgrading protocol servers. This enables additional provider combinations, such as terraform-plugin-sdk/v2 and terraform-plugin-framework.
Copy link

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.
If you have found a problem that seems similar to this, 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 May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants