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

Add support for boot_disk_type to google_dataproc_cluster #1855

Merged
merged 3 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions google/resource_dataproc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ func instanceConfigSchema() *schema.Schema {
ForceNew: true,
ValidateFunc: validation.IntAtLeast(10),
},

"boot_disk_type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"pd-standard", "pd-ssd", ""}, false),
Default: "pd-standard",
},
},
},
},
Expand Down Expand Up @@ -600,6 +608,9 @@ func expandInstanceGroupConfig(cfg map[string]interface{}) *dataproc.InstanceGro
if v, ok := dcfg["num_local_ssds"]; ok {
icg.DiskConfig.NumLocalSsds = int64(v.(int))
}
if v, ok := dcfg["boot_disk_type"]; ok {
icg.DiskConfig.BootDiskType = v.(string)
}
}
}
return icg
Expand Down Expand Up @@ -813,6 +824,7 @@ func flattenInstanceGroupConfig(d *schema.ResourceData, icg *dataproc.InstanceGr
if icg.DiskConfig != nil {
disk["boot_disk_size_gb"] = icg.DiskConfig.BootDiskSizeGb
disk["num_local_ssds"] = icg.DiskConfig.NumLocalSsds
disk["boot_disk_type"] = icg.DiskConfig.BootDiskType
}
}

Expand Down
18 changes: 12 additions & 6 deletions google/resource_dataproc_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestAccDataprocCluster_basic(t *testing.T) {
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.master_config.0.num_instances", "1"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.master_config.0.disk_config.0.boot_disk_size_gb"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.master_config.0.disk_config.0.num_local_ssds"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.master_config.0.disk_config.0.boot_disk_type"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.master_config.0.machine_type"),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.master_config.0.instance_names.#", "1"),

Expand All @@ -119,6 +120,7 @@ func TestAccDataprocCluster_basic(t *testing.T) {
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.worker_config.0.num_instances", "2"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.worker_config.0.disk_config.0.boot_disk_size_gb"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.worker_config.0.disk_config.0.num_local_ssds"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.worker_config.0.disk_config.0.boot_disk_type"),
resource.TestCheckResourceAttrSet("google_dataproc_cluster.basic", "cluster_config.0.worker_config.0.machine_type"),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.worker_config.0.instance_names.#", "2"),

Expand All @@ -132,7 +134,7 @@ func TestAccDataprocCluster_basic(t *testing.T) {
})
}

func TestAccDataprocCluster_basicWithInternalIpOnlyTrue(t *testing.T) {
func TestAccDataprocCluster_withInternalIpOnlyTrue(t *testing.T) {
t.Parallel()

var cluster dataproc.Cluster
Expand All @@ -143,7 +145,7 @@ func TestAccDataprocCluster_basicWithInternalIpOnlyTrue(t *testing.T) {
CheckDestroy: testAccCheckDataprocClusterDestroy(),
Steps: []resource.TestStep{
{
Config: testAccDataprocCluster_basicWithInternalIpOnlyTrue(rnd),
Config: testAccDataprocCluster_withInternalIpOnlyTrue(rnd),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataprocClusterExists("google_dataproc_cluster.basic", &cluster),

Expand All @@ -155,7 +157,7 @@ func TestAccDataprocCluster_basicWithInternalIpOnlyTrue(t *testing.T) {
})
}

func TestAccDataprocCluster_basicWithMetadata(t *testing.T) {
func TestAccDataprocCluster_withMetadata(t *testing.T) {
t.Parallel()

var cluster dataproc.Cluster
Expand All @@ -166,7 +168,7 @@ func TestAccDataprocCluster_basicWithMetadata(t *testing.T) {
CheckDestroy: testAccCheckDataprocClusterDestroy(),
Steps: []resource.TestStep{
{
Config: testAccDataprocCluster_basicWithMetadata(rnd),
Config: testAccDataprocCluster_withMetadata(rnd),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataprocClusterExists("google_dataproc_cluster.basic", &cluster),

Expand Down Expand Up @@ -534,12 +536,14 @@ func validateDataprocCluster_withConfigOverrides(n string, cluster *dataproc.Clu
{"cluster_config.0.master_config.0.num_instances", "3", strconv.Itoa(int(cluster.Config.MasterConfig.NumInstances))},
{"cluster_config.0.master_config.0.disk_config.0.boot_disk_size_gb", "10", strconv.Itoa(int(cluster.Config.MasterConfig.DiskConfig.BootDiskSizeGb))},
{"cluster_config.0.master_config.0.disk_config.0.num_local_ssds", "0", strconv.Itoa(int(cluster.Config.MasterConfig.DiskConfig.NumLocalSsds))},
{"cluster_config.0.master_config.0.disk_config.0.boot_disk_type", "pd-ssd", cluster.Config.MasterConfig.DiskConfig.BootDiskType},
{"cluster_config.0.master_config.0.machine_type", "n1-standard-1", GetResourceNameFromSelfLink(cluster.Config.MasterConfig.MachineTypeUri)},
{"cluster_config.0.master_config.0.instance_names.#", "3", strconv.Itoa(len(cluster.Config.MasterConfig.InstanceNames))},

{"cluster_config.0.worker_config.0.num_instances", "3", strconv.Itoa(int(cluster.Config.WorkerConfig.NumInstances))},
{"cluster_config.0.worker_config.0.disk_config.0.boot_disk_size_gb", "11", strconv.Itoa(int(cluster.Config.WorkerConfig.DiskConfig.BootDiskSizeGb))},
{"cluster_config.0.worker_config.0.disk_config.0.num_local_ssds", "1", strconv.Itoa(int(cluster.Config.WorkerConfig.DiskConfig.NumLocalSsds))},
{"cluster_config.0.worker_config.0.disk_config.0.boot_disk_type", "pd-standard", cluster.Config.WorkerConfig.DiskConfig.BootDiskType},
{"cluster_config.0.worker_config.0.machine_type", "n1-standard-1", GetResourceNameFromSelfLink(cluster.Config.WorkerConfig.MachineTypeUri)},
{"cluster_config.0.worker_config.0.instance_names.#", "3", strconv.Itoa(len(cluster.Config.WorkerConfig.InstanceNames))},

Expand Down Expand Up @@ -626,7 +630,7 @@ resource "google_dataproc_cluster" "basic" {
`, rnd)
}

func testAccDataprocCluster_basicWithInternalIpOnlyTrue(rnd string) string {
func testAccDataprocCluster_withInternalIpOnlyTrue(rnd string) string {
return fmt.Sprintf(`
variable subnetwork_cidr {
default = "10.0.0.0/16"
Expand Down Expand Up @@ -692,7 +696,7 @@ resource "google_dataproc_cluster" "basic" {
`, rnd, rnd, rnd)
}

func testAccDataprocCluster_basicWithMetadata(rnd string) string {
func testAccDataprocCluster_withMetadata(rnd string) string {
return fmt.Sprintf(`
resource "google_dataproc_cluster" "basic" {
name = "dproc-cluster-test-%s"
Expand Down Expand Up @@ -740,6 +744,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
num_instances = 3
machine_type = "n1-standard-1"
disk_config {
boot_disk_type = "pd-ssd"
boot_disk_size_gb = 10
}
}
Expand All @@ -748,6 +753,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
num_instances = 3
machine_type = "n1-standard-1"
disk_config {
boot_disk_type = "pd-standard"
boot_disk_size_gb = 11
num_local_ssds = 1
}
Expand Down
Loading