-
Notifications
You must be signed in to change notification settings - Fork 98
Consider having a waiting interface to satisfy to enable consistant waiting in most resources #665
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
Comments
Hi @remyleone 👋 Thank you for raising this feature request. If you have ideas/proposals around this area, it would be great to see them. There are potentially (at least) two ways to interpret this request, which it would be helpful to get clarification on. Are you referring to one or both of these?
Terraform core and the protocol does not provide any mechanisms to support either of these concepts natively at the moment. The protocol is currently request-response oriented and binary in whether the request was successful or not (e.g. error diagnostics). There is no way for providers to influence the UI during a request at the moment. Core also does not take into consideration whether an operation may have involved multiple underlying steps in the provider. It is dependent on the provider side (e.g. the SDK or provider code itself) to handle any nuance and respond accordingly into the protocol as its designed today. The first concept has been historically tracked in these issues: hashicorp/terraform-plugin-sdk#109 / hashicorp/terraform-plugin-sdk#145 / hashicorp/terraform#17267 Designing functionality around this must happen with changes to core and protocol, since neither support the concept of streaming with provider operations beyond the plugin-level stdout receiver for logs. Since Terraform acts as a client to the provider as a server, there's no way to push this information in the current RPCs, so its very likely that new RPCs would need to be designed for this purpose. The second concept has been historically tracked in a few issues. One of those issues being tracked with hashicorp/terraform-plugin-sdk#330 is where an Designing functionality around this, whether in concert with changes to core and the protocol, do however require very careful consideration. For example, to properly enable providers to opt out of taint on creation requires some major overhaul in the core logic for how provisioners are handled. Provisioner execution is directly tied to their associated resource instance execution. Supporting a resource state which denotes that its provisioners are still yet to run requires new nodes in the graph and state storage for them. If functionality for this is to be designed in the framework, it will need to account for being generic and handling various edge cases and nuances associated with the way the ecosystem of providers and their APIs are designed. As we discovered over time with the prior SDK, a less than ideal codified abstraction can be worse than providing general design guidance. Hopefully some of the additional context helps here. |
Thanks for the very detailed answer :) I was thinking about the first interpretation but it could apply to the second interpretation as well. My main goal was to be very explicit about whether or not the plugin is running or blocking because of its wait on external resources. Because it is very oriented towards request/response it is not easy to signal when we start waiting for an operation and when it is over. Maybe having a way in the SDK to signal that we are currently waiting could be helpful to tackle other operations in the meantime. I understand that it could mean some massive refactoring. In the meantime, it could be useful to have in the documentation an additional example that depicts the system currently waiting. In particular, it could be very helpful to see how as an SDK writer I can use the context to see if I should cancel a wait operation because it already timed out. Ideally, I would like to see also how a graceful timeout could be signaled to the terraform core. |
In the meantime I think there is an issue with the documentation presented here: it says to use a https://pkg.go.dev/github.com/hashicorp/[email protected]/resource/timeouts I don't find anything that matches this function signature. |
Hi @remyleone 👋 I believe the documentation was fixed in Document Relationships Between Terraform Commands, Protocol RPCs, and Framework Functionality which will be released as part of the changes for |
Hey @remyleone, Hope you enjoy |
Nice feature |
Usually, you have to wait for a resource to reach a certain state before being considered stable. Could it be possible to have a way to define in terraform framework an interface that would enable terraform to know when it is waiting for a resource to be available?
Anyhow it would be useful to have a consistent pattern to wait in a standard fashion.
The text was updated successfully, but these errors were encountered: