From 2d7b7ba7378ea2dce299992f2fef1148c4c9e648 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Fri, 9 Oct 2020 21:27:15 +0000 Subject: [PATCH] Added field graceful_decomissioning_timeout to resource dataproc_cluster (#4078) * 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-beta/resource_dataproc_cluster.go | 13 ++++++++++++- google-beta/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 0000000000..0c2265166b --- /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-beta/resource_dataproc_cluster.go b/google-beta/resource_dataproc_cluster.go index ef7fc58cf9..6af5a6cb6b 100644 --- a/google-beta/resource_dataproc_cluster.go +++ b/google-beta/resource_dataproc_cluster.go @@ -115,6 +115,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, @@ -1238,9 +1245,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-beta/resource_dataproc_cluster_test.go b/google-beta/resource_dataproc_cluster_test.go index b1fe626a99..f0cb966d70 100644 --- a/google-beta/resource_dataproc_cluster_test.go +++ b/google-beta/resource_dataproc_cluster_test.go @@ -1218,6 +1218,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 { @@ -1586,7 +1587,7 @@ resource "google_dataproc_cluster" "basic" { } } } - + resource "google_dataproc_autoscaling_policy" "asp" { policy_id = "tf-test-dataproc-policy-%s" location = "us-central1" @@ -1618,7 +1619,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 bfd038ac3e..da12e76754 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