Skip to content

Commit d4b7016

Browse files
support SPOT for secondary worker. (#7000) (#13335)
* support SPOT for secondary worker. * remove version guard for SPOT * rerun * remove trailing space Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent b52f2ba commit d4b7016

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

.changelog/7000.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
dataproc: added support for `SPOT` option for `preemptibility` in `google_dataproc_cluster`
3+
```

google/resource_dataproc_cluster.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ func resourceDataprocCluster() *schema.Resource {
669669
"cluster_config.0.preemptible_worker_config.0.disk_config",
670670
},
671671
ForceNew: true,
672-
ValidateFunc: validation.StringInSlice([]string{"PREEMPTIBILITY_UNSPECIFIED", "NON_PREEMPTIBLE", "PREEMPTIBLE"}, false),
672+
ValidateFunc: validation.StringInSlice([]string{"PREEMPTIBILITY_UNSPECIFIED", "NON_PREEMPTIBLE", "PREEMPTIBLE", "SPOT"}, false),
673673
Default: "PREEMPTIBLE",
674674
},
675675

google/resource_dataproc_cluster_test.go

+56
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,27 @@ func TestAccDataprocCluster_nonPreemptibleSecondary(t *testing.T) {
450450
})
451451
}
452452

453+
func TestAccDataprocCluster_spotSecondary(t *testing.T) {
454+
t.Parallel()
455+
456+
rnd := randString(t, 10)
457+
var cluster dataproc.Cluster
458+
vcrTest(t, resource.TestCase{
459+
PreCheck: func() { testAccPreCheck(t) },
460+
Providers: testAccProviders,
461+
CheckDestroy: testAccCheckDataprocClusterDestroy(t),
462+
Steps: []resource.TestStep{
463+
{
464+
Config: testAccDataprocCluster_spotSecondary(rnd),
465+
Check: resource.ComposeTestCheckFunc(
466+
testAccCheckDataprocClusterExists(t, "google_dataproc_cluster.spot_secondary", &cluster),
467+
resource.TestCheckResourceAttr("google_dataproc_cluster.spot_secondary", "cluster_config.0.preemptible_worker_config.0.preemptibility", "SPOT"),
468+
),
469+
},
470+
},
471+
})
472+
}
473+
453474
func TestAccDataprocCluster_withStagingBucket(t *testing.T) {
454475
t.Parallel()
455476

@@ -1498,6 +1519,41 @@ resource "google_dataproc_cluster" "non_preemptible_secondary" {
14981519
`, rnd)
14991520
}
15001521

1522+
func testAccDataprocCluster_spotSecondary(rnd string) string {
1523+
return fmt.Sprintf(`
1524+
resource "google_dataproc_cluster" "spot_secondary" {
1525+
name = "tf-test-dproc-%s"
1526+
region = "us-central1"
1527+
1528+
cluster_config {
1529+
master_config {
1530+
num_instances = "1"
1531+
machine_type = "e2-medium"
1532+
disk_config {
1533+
boot_disk_size_gb = 35
1534+
}
1535+
}
1536+
1537+
worker_config {
1538+
num_instances = "2"
1539+
machine_type = "e2-medium"
1540+
disk_config {
1541+
boot_disk_size_gb = 35
1542+
}
1543+
}
1544+
1545+
preemptible_worker_config {
1546+
num_instances = "1"
1547+
preemptibility = "SPOT"
1548+
disk_config {
1549+
boot_disk_size_gb = 35
1550+
}
1551+
}
1552+
}
1553+
}
1554+
`, rnd)
1555+
}
1556+
15011557
func testAccDataprocCluster_withStagingBucketOnly(bucketName string) string {
15021558
return fmt.Sprintf(`
15031559
resource "google_storage_bucket" "bucket" {

website/docs/r/dataproc_cluster.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ will be set for you based on whatever was set for the `worker_config.machine_typ
604604
* PREEMPTIBILITY_UNSPECIFIED
605605
* NON_PREEMPTIBLE
606606
* PREEMPTIBLE
607+
* SPOT
607608

608609
* `disk_config` (Optional) Disk Config
609610

0 commit comments

Comments
 (0)