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

Consider Automatic Handling of GetProviderSchema ServerCapabilities PlanDestroy #131

Closed
bflad opened this issue Jan 30, 2023 · 1 comment · Fixed by #133
Closed

Consider Automatic Handling of GetProviderSchema ServerCapabilities PlanDestroy #131

bflad opened this issue Jan 30, 2023 · 1 comment · Fixed by #133
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Jan 30, 2023

terraform-plugin-mux version

v0.8.0

Use cases

Provider developers wishing to take advantage of resource destroy planning in Terraform 1.3+ with the framework currently cannot do so since the mux servers do not account for the new ServerCapabilties data from GetProviderSchema responses. This support is enabled in framework servers automatically because it could afford the breaking change before it reached GA. This support is not being considered directly in sdk/v2 servers because it is a breaking change for existing CustomizeDiff code, could potentially break SDK code, and regardless would require some sort of change in the mux code to enable it anyhow.

Attempted solutions

Since the mux server code does wholly manages the GetProviderSchema response, there is no current mux server workaround except not muxing and only serving a framework server directly.

Provider developers can leverage diagnostics during ApplyResourceChange by including the same logic in Delete functions/methods. This would be recommended for any provider which might need to support Terraform version prior to 1.3 anyways, since those practitioners would never see the PlanResourceChange diagnostics. One non-limitation is that plan logic can inspect configuration while apply logic cannot. This is not valid however, because apply logic in this case only has access to prior state, so it'd never be possible to use configuration values during apply.

Proposal

In the mux servers, automatically drop (in a Terraform-valid way) PlanResourceChange requests if the mux server determined that the underlying provider server for the given resource type didn't ask to enable it from it's GetProviderSchema response ServerCapabilities. The mux server would then likely need to always enable (or OR together) the ServerCapabilities.

Abandoned Ideas

  • Have the mux server collect and automatically pass through the most "enabled" ServerCapabilities -- this means that provider developers immediately would have to deal with any breaking changes to CustomizeDiff or the sdk/v2 code itself, etc. code just by trying to mux servers together.
  • Allow provider developers to opt-into configuring a tfprotov5.ServerCapabilities/tfprotov6.ServerCapabilities object during mux server creation. This will ensure that provider developers have exact control over what potential server capabilities are enabled across all their provider servers, although it does require additional discovery that will need to be called out in the framework documentation for the feature.
  • Implement the above but let folks configure ServerCapabilities on the framework server. This would mean either discovering how to disable it or changing the default behavior (breaking change) and discovering how to enable it.
  • Warn about the current situation (?) I’m not sure if there’s any value in this option since practitioners and provider developers could never fix it

References

@bflad bflad added enhancement New feature or request tf-devex-triage labels Jan 30, 2023
@bflad bflad added this to the v0.9.0 milestone Feb 1, 2023
@bflad bflad self-assigned this Feb 1, 2023
@bflad bflad changed the title Consider Opt-In Configuration of GetProviderSchema ServerCapabilities Consider Automatic Handling of GetProviderSchema ServerCapabilities PlanDestroy Feb 1, 2023
bflad added a commit that referenced this issue Feb 2, 2023
…apabilities

Reference: #131

First, this enables the mux servers to capture and handle underlying `GetProviderSchema` RPC response `ServerCapabilities`. The first capability supported is `PlanDestroy`, which in Terraform 1.3+ will trigger Terraform to send the `PlanResourceChange` RPC to the provider during resource destroy. Any server capabilities enabled across the underlying servers use a logical OR to form the single mux server response.

Enabling the RPC in that scenario unexpectedly for providers could cause either SDK or provider errors and panics. While the mux server will unilaterally enable the behavior for any resource type by nature of the single boolean field across the protocol, it will attempt to filter `PlanResourceChange` calls based on whether the underlying server signaled the capability. If determined to be a destroy plan and the server does not enable the capability, the mux server will send its own response without calling the underlying server.
bflad added a commit that referenced this issue Feb 7, 2023
…apabilities

Reference: #131

First, this enables the mux servers to capture and handle underlying `GetProviderSchema` RPC response `ServerCapabilities`. The first capability supported is `PlanDestroy`, which in Terraform 1.3+ will trigger Terraform to send the `PlanResourceChange` RPC to the provider during resource destroy. Any server capabilities enabled across the underlying servers use a logical OR to form the single mux server response.

Enabling the RPC in that scenario unexpectedly for providers could cause either SDK or provider errors and panics. While the mux server will unilaterally enable the behavior for any resource type by nature of the single boolean field across the protocol, it will attempt to filter `PlanResourceChange` calls based on whether the underlying server signaled the capability. If determined to be a destroy plan and the server does not enable the capability, the mux server will send its own response without calling the underlying server.
@bflad bflad closed this as completed in #133 Feb 8, 2023
bflad added a commit that referenced this issue Feb 8, 2023
…apabilities (#133)

Reference: #131

This enables the mux servers to send the `GetProviderSchema` RPC response `ServerCapabilities`. The first capability supported is `PlanDestroy`, which in Terraform 1.3+ will trigger Terraform to send the `PlanResourceChange` RPC to the provider during resource destroy.

Enabling the RPC in that scenario unexpectedly for providers could cause either SDK or provider errors and panics. While the mux server will unilaterally enable the behavior for any resource type by nature of the single boolean field across the protocol, it will attempt to filter `PlanResourceChange` calls based on whether the underlying server signaled the capability. If determined to be a destroy plan and the server does not enable the capability, the mux server will send its own response without calling the underlying server.
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
1 participant