Skip to content

Commit 79593d7

Browse files
authored
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
1 parent 51be571 commit 79593d7

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

third_party/terraform/resources/resource_dataproc_cluster.go.erb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ func resourceDataprocCluster() *schema.Resource {
118118
Description: `The region in which the cluster and associated nodes will be created in. Defaults to global.`,
119119
},
120120

121+
"graceful_decommission_timeout": {
122+
Type: schema.TypeString,
123+
Optional: true,
124+
Default: "0s",
125+
Description: `The timeout duration which allows graceful decomissioning when you change the number of worker nodes directly through a terraform apply`,
126+
},
127+
128+
121129
"labels": {
122130
Type: schema.TypeMap,
123131
Optional: true,
@@ -1250,9 +1258,13 @@ func resourceDataprocClusterUpdate(d *schema.ResourceData, meta interface{}) err
12501258
<% end -%>
12511259

12521260
if len(updMask) > 0 {
1261+
gracefulDecommissionTimeout := d.Get("graceful_decommission_timeout").(string)
1262+
12531263
patch := config.NewDataprocBetaClient(userAgent).Projects.Regions.Clusters.Patch(
12541264
project, region, clusterName, cluster)
1255-
op, err := patch.UpdateMask(strings.Join(updMask, ",")).Do()
1265+
patch.GracefulDecommissionTimeout(gracefulDecommissionTimeout)
1266+
patch.UpdateMask(strings.Join(updMask, ","))
1267+
op, err := patch.Do()
12561268
if err != nil {
12571269
return err
12581270
}

third_party/terraform/tests/resource_dataproc_cluster_test.go.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@ func testAccDataprocCluster_updatable(rnd string, w, p int) string {
12221222
resource "google_dataproc_cluster" "updatable" {
12231223
name = "tf-test-dproc-%s"
12241224
region = "us-central1"
1225+
graceful_decommission_timeout = "0.2s"
12251226

12261227
cluster_config {
12271228
master_config {
@@ -1594,7 +1595,7 @@ resource "google_dataproc_cluster" "basic" {
15941595
}
15951596
}
15961597
}
1597-
1598+
15981599
resource "google_dataproc_autoscaling_policy" "asp" {
15991600
policy_id = "tf-test-dataproc-policy-%s"
16001601
location = "us-central1"
@@ -1626,7 +1627,7 @@ resource "google_dataproc_cluster" "basic" {
16261627
}
16271628
}
16281629
}
1629-
1630+
16301631
resource "google_dataproc_autoscaling_policy" "asp" {
16311632
policy_id = "tf-test-dataproc-policy-%s"
16321633
location = "us-central1"

third_party/terraform/website/docs/r/dataproc_cluster.html.markdown

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ resource "google_dataproc_cluster" "simplecluster" {
3232
resource "google_dataproc_cluster" "mycluster" {
3333
name = "mycluster"
3434
region = "us-central1"
35+
graceful_decommission_timeout = "120s"
3536
labels = {
3637
foo = "bar"
3738
}
@@ -131,6 +132,14 @@ resource "google_dataproc_cluster" "accelerated_cluster" {
131132
* `cluster_config` - (Optional) Allows you to configure various aspects of the cluster.
132133
Structure defined below.
133134

135+
* `graceful_decommission_timout` - (Optional) Allows graceful decomissioning when you change the number of worker nodes directly through a terraform apply.
136+
Does not affect auto scaling decomissioning from an autoscaling policy.
137+
Graceful decommissioning allows removing nodes from the cluster without interrupting jobs in progress.
138+
Timeout specifies how long to wait for jobs in progress to finish before forcefully removing nodes (and potentially interrupting jobs).
139+
Default timeout is 0 (for forceful decommission), and the maximum allowed timeout is 1 day. (see JSON representation of
140+
[Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
141+
Only supported on Dataproc image versions 1.2 and higher.
142+
For more context see the [docs](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.clusters/patch#query-parameters)
134143
- - -
135144

136145
The `cluster_config` block supports:
@@ -240,10 +249,10 @@ The `cluster_config.gce_cluster_config` block supports:
240249
* `tags` - (Optional) The list of instance tags applied to instances in the cluster.
241250
Tags are used to identify valid sources or targets for network firewalls.
242251

243-
* `internal_ip_only` - (Optional) By default, clusters are not restricted to internal IP addresses,
244-
and will have ephemeral external IP addresses assigned to each instance. If set to true, all
245-
instances in the cluster will only have internal IP addresses. Note: Private Google Access
246-
(also known as `privateIpGoogleAccess`) must be enabled on the subnetwork that the cluster
252+
* `internal_ip_only` - (Optional) By default, clusters are not restricted to internal IP addresses,
253+
and will have ephemeral external IP addresses assigned to each instance. If set to true, all
254+
instances in the cluster will only have internal IP addresses. Note: Private Google Access
255+
(also known as `privateIpGoogleAccess`) must be enabled on the subnetwork that the cluster
247256
will be launched in.
248257

249258
* `metadata` - (Optional) A map of the Compute Engine metadata entries to add to all instances
@@ -436,7 +445,7 @@ cluster_config {
436445
a cluster. For a list of valid properties please see
437446
[Cluster properties](https://cloud.google.com/dataproc/docs/concepts/cluster-properties)
438447

439-
* `optional_components` - (Optional) The set of optional components to activate on the cluster.
448+
* `optional_components` - (Optional) The set of optional components to activate on the cluster.
440449
Accepted values are:
441450
* ANACONDA
442451
* DRUID

0 commit comments

Comments
 (0)