From 91c0de1fd17bd3ff7797e5d86a94f9dcf7c25f35 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 9 Oct 2020 14:27:46 -0700 Subject: [PATCH] Added field graceful_decomissioning_timeout to resource dataproc_cluster (#4078) (#7485) * Added field graceful_decomissioning_timeout to resource dataproc_cluster * formating * fix formatting concerns and removed api.yaml edits since resource is handwritten Signed-off-by: Modular Magician --- .changelog/4078.txt | 3 +++ google/resource_dataproc_cluster.go | 13 ++++++++++++- google/resource_dataproc_cluster_test.go | 5 +++-- website/docs/r/dataproc_cluster.html.markdown | 19 ++++++++++++++----- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 .changelog/4078.txt diff --git a/.changelog/4078.txt b/.changelog/4078.txt new file mode 100644 index 00000000000..0c2265166b1 --- /dev/null +++ b/.changelog/4078.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +dataproc: Added `graceful_decomissioning_timeout` field to `dataproc_cluster` resource +``` diff --git a/google/resource_dataproc_cluster.go b/google/resource_dataproc_cluster.go index efe39c2b0db..eee9fcf9656 100644 --- a/google/resource_dataproc_cluster.go +++ b/google/resource_dataproc_cluster.go @@ -113,6 +113,13 @@ func resourceDataprocCluster() *schema.Resource { Description: `The region in which the cluster and associated nodes will be created in. Defaults to global.`, }, + "graceful_decommission_timeout": { + Type: schema.TypeString, + Optional: true, + Default: "0s", + Description: `The timeout duration which allows graceful decomissioning when you change the number of worker nodes directly through a terraform apply`, + }, + "labels": { Type: schema.TypeMap, Optional: true, @@ -1125,9 +1132,13 @@ func resourceDataprocClusterUpdate(d *schema.ResourceData, meta interface{}) err } if len(updMask) > 0 { + gracefulDecommissionTimeout := d.Get("graceful_decommission_timeout").(string) + patch := config.NewDataprocBetaClient(userAgent).Projects.Regions.Clusters.Patch( project, region, clusterName, cluster) - op, err := patch.UpdateMask(strings.Join(updMask, ",")).Do() + patch.GracefulDecommissionTimeout(gracefulDecommissionTimeout) + patch.UpdateMask(strings.Join(updMask, ",")) + op, err := patch.Do() if err != nil { return err } diff --git a/google/resource_dataproc_cluster_test.go b/google/resource_dataproc_cluster_test.go index 4a8573f5a61..12b2f1e56e5 100644 --- a/google/resource_dataproc_cluster_test.go +++ b/google/resource_dataproc_cluster_test.go @@ -1139,6 +1139,7 @@ func testAccDataprocCluster_updatable(rnd string, w, p int) string { resource "google_dataproc_cluster" "updatable" { name = "tf-test-dproc-%s" region = "us-central1" + graceful_decommission_timeout = "0.2s" cluster_config { master_config { @@ -1462,7 +1463,7 @@ resource "google_dataproc_cluster" "basic" { } } } - + resource "google_dataproc_autoscaling_policy" "asp" { policy_id = "tf-test-dataproc-policy-%s" location = "us-central1" @@ -1494,7 +1495,7 @@ resource "google_dataproc_cluster" "basic" { } } } - + resource "google_dataproc_autoscaling_policy" "asp" { policy_id = "tf-test-dataproc-policy-%s" location = "us-central1" diff --git a/website/docs/r/dataproc_cluster.html.markdown b/website/docs/r/dataproc_cluster.html.markdown index bfd038ac3e2..da12e76754e 100644 --- a/website/docs/r/dataproc_cluster.html.markdown +++ b/website/docs/r/dataproc_cluster.html.markdown @@ -32,6 +32,7 @@ resource "google_dataproc_cluster" "simplecluster" { resource "google_dataproc_cluster" "mycluster" { name = "mycluster" region = "us-central1" + graceful_decommission_timeout = "120s" labels = { foo = "bar" } @@ -131,6 +132,14 @@ resource "google_dataproc_cluster" "accelerated_cluster" { * `cluster_config` - (Optional) Allows you to configure various aspects of the cluster. Structure defined below. +* `graceful_decommission_timout` - (Optional) Allows graceful decomissioning when you change the number of worker nodes directly through a terraform apply. + Does not affect auto scaling decomissioning from an autoscaling policy. + Graceful decommissioning allows removing nodes from the cluster without interrupting jobs in progress. + Timeout specifies how long to wait for jobs in progress to finish before forcefully removing nodes (and potentially interrupting jobs). + Default timeout is 0 (for forceful decommission), and the maximum allowed timeout is 1 day. (see JSON representation of + [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)). + Only supported on Dataproc image versions 1.2 and higher. + For more context see the [docs](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.clusters/patch#query-parameters) - - - The `cluster_config` block supports: @@ -240,10 +249,10 @@ The `cluster_config.gce_cluster_config` block supports: * `tags` - (Optional) The list of instance tags applied to instances in the cluster. Tags are used to identify valid sources or targets for network firewalls. -* `internal_ip_only` - (Optional) By default, clusters are not restricted to internal IP addresses, - and will have ephemeral external IP addresses assigned to each instance. If set to true, all - instances in the cluster will only have internal IP addresses. Note: Private Google Access - (also known as `privateIpGoogleAccess`) must be enabled on the subnetwork that the cluster +* `internal_ip_only` - (Optional) By default, clusters are not restricted to internal IP addresses, + and will have ephemeral external IP addresses assigned to each instance. If set to true, all + instances in the cluster will only have internal IP addresses. Note: Private Google Access + (also known as `privateIpGoogleAccess`) must be enabled on the subnetwork that the cluster will be launched in. * `metadata` - (Optional) A map of the Compute Engine metadata entries to add to all instances @@ -436,7 +445,7 @@ cluster_config { a cluster. For a list of valid properties please see [Cluster properties](https://cloud.google.com/dataproc/docs/concepts/cluster-properties) -* `optional_components` - (Optional) The set of optional components to activate on the cluster. +* `optional_components` - (Optional) The set of optional components to activate on the cluster. Accepted values are: * ANACONDA * DRUID