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

dataflow job update-by-replacement #3387

Merged

Conversation

c2thorn
Copy link
Member

@c2thorn c2thorn commented Apr 18, 2020

Fixes hashicorp/terraform-provider-google#5991

  • Adds update-by-replacement method
  • Separates ForceNew functionality based on JOB_TYPE
  • Triggers diffs based on reading the new template_md5hash

Release Note Template for Downstream PRs (will be copied)

dataflow: Added support for update-by-replacement to `google_dataflow_job`
dataflow: Added drift detection for `google_dataflow_job` `template_gcs_path` and `temp_gcs_location` fields

@c2thorn c2thorn force-pushed the dataflow-update-by-replacement branch from b8ce119 to 1123f40 Compare April 18, 2020 02:21
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 198 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 2 files changed, 198 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 205 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 3 files changed, 205 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 206 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 3 files changed, 206 insertions(+), 13 deletions(-))

1 similar comment
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 206 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 3 files changed, 206 insertions(+), 13 deletions(-))

@c2thorn c2thorn requested a review from danawillow April 20, 2020 17:10
params := expandStringMap(d, "parameters")
labels := expandStringMap(d, "labels")

env := dataflow.RuntimeEnvironment{
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be made into a function that can be called from both create and update?

third_party/terraform/resources/resource_dataflow_job.go Outdated Show resolved Hide resolved
third_party/terraform/tests/resource_dataflow_job_test.go Outdated Show resolved Hide resolved
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 206 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 3 files changed, 206 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 217 insertions(+), 29 deletions(-))
Terraform Beta: Diff ( 3 files changed, 217 insertions(+), 29 deletions(-))

@c2thorn c2thorn requested a review from danawillow April 20, 2020 23:56
Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

For the changelog, I think (but you'll want to verify) you can actually separate it out into two different release note blocks. That way you could do one enhancement block for the new changes, and another note or breaking-change block for the other stuff.

@@ -182,6 +183,35 @@ func TestAccDataflowJob_withIpConfig(t *testing.T) {
})
}

func TestAccDataflowJob_streamUpdate(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, how possible would it be to do one that tests the contents of the template changing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be possible, and a good test to add. I'll cook one up.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 215 insertions(+), 27 deletions(-))
Terraform Beta: Diff ( 3 files changed, 215 insertions(+), 27 deletions(-))

@c2thorn c2thorn force-pushed the dataflow-update-by-replacement branch from 3f6bdb5 to b479f2d Compare April 29, 2020 18:09
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 192 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 3 files changed, 192 insertions(+), 13 deletions(-))
TF Conversion: Diff ( 1 file changed, 9 insertions(+))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 198 insertions(+), 13 deletions(-))
Terraform Beta: Diff ( 3 files changed, 198 insertions(+), 13 deletions(-))
TF Conversion: Diff ( 1 file changed, 9 insertions(+))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 214 insertions(+), 32 deletions(-))
Terraform Beta: Diff ( 3 files changed, 214 insertions(+), 32 deletions(-))
TF Conversion: Diff ( 1 file changed, 9 insertions(+))

@c2thorn
Copy link
Member Author

c2thorn commented Apr 29, 2020

Reverted all of the template hash logic, modified the update test, and added a retry to the update-by-replacement call.

@c2thorn c2thorn requested a review from danawillow April 29, 2020 22:00
Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

LGTM assuming tests pass

return err
}
optionsMap := sdkPipelineOptions["options"].(map[string]interface{})
d.Set("template_gcs_path", optionsMap["templateLocation"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add to the CHANGELOG that we now detect drift on these fields?

}
on_delete = "cancel"
}
`, suffix, suffix, suffix, suffix, testDataflowJobTemplateTextToPubsub, tempLocation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the last two params here be switched?

Copy link
Member Author

Choose a reason for hiding this comment

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

The field names are confusing, but it is correct as it is. template_gcs_path needs to remain fixed, temp_gcs_location is the field I am actually updating.

@c2thorn
Copy link
Member Author

c2thorn commented Apr 30, 2020

Ran all dataflow tests in TC, looks good.

@@ -100,13 +103,13 @@ func resourceDataflowJob() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{"cancel", "drain"}, false),
Copy link
Member

Choose a reason for hiding this comment

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

Hi @c2thorn, does this mean that changes to on_delete would also trigger an update-by-replacement?

Copy link
Member Author

@c2thorn c2thorn May 5, 2020

Choose a reason for hiding this comment

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

Hi, yes that is true. Previously any changes to on_delete would destroy/recreate both stream or batch jobs. Now it will trigger the update-by-replacement for streaming jobs, while retaining the same destroy/recreate functionality for batch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh that's interesting that we used to ForceNew on that! It probably should be something that can be updatable completely on its own, without triggering a ForceNew or an update-by-replacement.

Copy link
Member

@jcanseco jcanseco May 5, 2020

Choose a reason for hiding this comment

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

Ah yeah I was surprised to see that it used to be ForceNew as well.

I agree that this field should be updatable on its own without triggering a ForceNew or update-by-replacement. Would you like me to file this as a separate issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

nathkn pushed a commit to nathkn/magic-modules that referenced this pull request May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Dataflow job "update-by-replacement"
5 participants