-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Enabling management of default Dialogflow resources without terraform import: is_default_x
fields
#9336
Conversation
…Default Negative Intent, without terraform import Fixes hashicorp/terraform-provider-google#16308
Hello! I am a robot. It looks like you are a: @SarahFrench, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
This comment was marked as outdated.
This comment was marked as outdated.
FYI, setting the So there's no users that should be broken here. UPDATE: ugh, I thought of a case where this might break existing users: if they'd |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 I just did an initial pass after reading the issue - I need to have another proper look at the tests but I identified a required schema change that should be addressed first.
Also, I added a release note about the field being changed from an argument to an output/attribute. From what you've described making that change in this PR isn't a problem despite it being a breaking change
Good catch, thanks! |
@SarahFrench @rileykarson I think it might be possible to handle this case by making the name field optional + computed instead of adding these new fields / complex behavior? Similar to
|
That resource is O+C to support a The Azure provider experimented with more general acquire-on-create because most Azure APIs are Upsert APIs, and actively took steps to walk that back: https://github.com/hashicorp/terraform-provider-azurerm/blob/497f844925d50321ee1eea10bb1d7c13662828ea/website/docs/guides/2.0-upgrade-guide.html.markdown#changes-when-importing-existing-resources We want to avoid that because it makes Terraform much more likely to touch unintended settings- acquire-on-create does not message what it is doing in plan. |
If we have a different resource doing something similar as precedent, we should consider that (and I highlighted one potential one in chat for Sarah to consider referencing, logging bucket config)- but please don't use https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/workflows_workflow as a precedent for this change as it's completely different. |
PS to be clear, I don't have a horse in this race, I just want one no-argument |
@rileykarson I'm not saying that google_workflows_workflow is a precedent for acquire-on-create. My understanding from talking to @mmurakowski-verily was that creating this resource with no name set ends up using the default name - so using O+C would be an acceptable way to represent that, similar to google_workflows_workflow (and other resources) that have a name that is either set by the server or the user. It sounds like there may have been a misunderstanding if that's not accurate. |
What's different here is that there's a single singleton per-parent, and all other resources of this kind can be managed entirely through Terraform. For those Terraform-managed ones the name is server-defined (and the singletons have a fixed name). In Workflows the name is client-defined and we're computing a name entirely locally- see https://cloud.google.com/workflows/docs/reference/rest/v1/projects.locations.workflows/create#query-parameters, the name is a required field. We're just setting it in the encoder when unset in config. There are similarities at a surface level (both can have a name determined at apply-time) but they're not cases of the same problem. Some much closer cases are https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/logging_project_bucket_config and https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/firestore_database where there's a singleton (or two, in logging's case) and other instances can be entirely Terraform-managed. |
…the Default Negative Intent :(
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 8 files changed, 661 insertions(+), 1 deletion(-)) |
Tests analyticsTotal tests: Action takenFound 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccDataprocClusterIamPolicy|TestAccDialogflowCXIntent_dialogflowcxIntentDefaultNegativeIntentExample|TestAccDialogflowCXIntent_defaultIntents|TestAccHealthcareDatasetIamPolicy |
Rerun these tests in REPLAYING mode to catch issues
|
yeah, I misunderstood the ask from @mmurakowski-verily and thought this was much simpler than it is. My bad & thanks for the additional context. It seems like the implementation proposed here would allow users to more smoothly set up an agent and the default flow without needing to have an additional step to import it
At the risk of proposing another option that makes no sense: It feels like the most intuitive way to handle this in Terraform would be to assume that users generally want to create new flows, not use the default flow. I'm not quite clear on whether the default flows have a "special status" - for example, It seems like flows / intents aren't really singletons, just easily available defaults. @mmurakowski-verily can you confirm? How necessary is it to use the default flows / intents? If so - we could potentially switch to an Optional + Computed field for name (should be backwards-compatible since the field is already in state?) and for new resources folks could have a choice between importing the default resource or setting an explicit id? |
Hm, taking another look - using O+C would only make sense if the API allows users specifying an ID at create time - so that would only make sense if the create method supports the name being passed in the body (which would be a little unusual - standard behavior is to pass it in the URL) |
I'm not going to leave any more comments on here to avoid muddying the waters here more 😂 Sarah is the reviewer. |
@SarahFrench I've re-opened this + #9359; pick the one you like, or tell me to write a new one for Thanks in advance for doing the hard part of this process. |
is_default_x
fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the wait - here's a review that's mostly me asking for small updates to help users and maintainers notice that the new virtual fields don't follow assumptions they may have about how resources behave.
I did a bunch of manual testing of the code changes and everything worked as expected 🎉 I may do one more review but this PR feels mostly finished already 😁
mmv1/third_party/terraform/services/dialogflowcx/resource_dialogflowcx_flow_test.go
Show resolved
Hide resolved
mmv1/third_party/terraform/services/dialogflowcx/resource_dialogflowcx_intent_test.go
Show resolved
Hide resolved
mmv1/third_party/terraform/services/dialogflowcx/resource_dialogflowcx_flow_test.go
Show resolved
Hide resolved
mmv1/templates/terraform/pre_create/dialogflowcx_set_location_skip_default_obj.go.erb
Outdated
Show resolved
Hide resolved
…skip_default_obj.go.erb Co-authored-by: Sarah French <[email protected]>
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 8 files changed, 663 insertions(+), 1 deletion(-)) |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 8 files changed, 675 insertions(+), 1 deletion(-)) |
Tests analyticsTotal tests:
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 8 files changed, 842 insertions(+), 1 deletion(-)) |
Tests analyticsTotal tests: Action takenFound 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccDialogflowCXFlow_defaultStartFlow|TestAccDialogflowCXIntent_defaultIntents |
Rerun these tests in REPLAYING mode to catch issues
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 @mmurakowski-verily I'm happy to go ahead and merge; the changes to the resources behave as expected and we've included a bunch of notices to maintainers and users about the atypical behaviour of the resource when these virtual fields are used.
Thank you for this contribution, and also for expanding what we can do with virtual fields!
… import: `is_default_x` fields (GoogleCloudPlatform#9336) * Enabling management of Default Start Flow + Default Welcome Intent + Default Negative Intent, without terraform import Fixes hashicorp/terraform-provider-google#16308 * Basic tests for default flow + intents * Tests asserting resource IDs * Making Flow + Intent import respect is_default_X; fixing description on examples * Bah, making isFallback output-only might break users that'd imported the Default Negative Intent :( * Update mmv1/templates/terraform/pre_create/dialogflowcx_set_location_skip_default_obj.go.erb Co-authored-by: Sarah French <[email protected]> * Adding callout notes about multiple is_default_x resources * More words around the pre-create + pre-delete code * Adding more tests around Default Start Flow * Adding more tests around Default Welcome Intent and Default Negative Intent --------- Co-authored-by: Sarah French <[email protected]>
… import: `is_default_x` fields (GoogleCloudPlatform#9336) * Enabling management of Default Start Flow + Default Welcome Intent + Default Negative Intent, without terraform import Fixes hashicorp/terraform-provider-google#16308 * Basic tests for default flow + intents * Tests asserting resource IDs * Making Flow + Intent import respect is_default_X; fixing description on examples * Bah, making isFallback output-only might break users that'd imported the Default Negative Intent :( * Update mmv1/templates/terraform/pre_create/dialogflowcx_set_location_skip_default_obj.go.erb Co-authored-by: Sarah French <[email protected]> * Adding callout notes about multiple is_default_x resources * More words around the pre-create + pre-delete code * Adding more tests around Default Start Flow * Adding more tests around Default Welcome Intent and Default Negative Intent --------- Co-authored-by: Sarah French <[email protected]>
Fixes hashicorp/terraform-provider-google#16308, read that bug for more context 😅
An alternative version of #9359 because designing a good API is hard and I want someone else to make that decision 😅.
Release Note Template for Downstream PRs (will be copied)