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

fix beta dataproc resources by adding min_cpu_platform in master/worker config instead of preemptible #848

Merged
merged 1 commit into from
Jun 17, 2019
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
13 changes: 7 additions & 6 deletions google-beta/resource_dataproc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,7 @@ func resourceDataprocCluster() *schema.Resource {
// API does not honour this if set ...
// It always uses whatever is specified for the worker_config
// "machine_type": { ... }
"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
// "min_cpu_platform": { ... }
"disk_config": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -363,6 +358,12 @@ func instanceConfigSchema() *schema.Schema {
ForceNew: true,
},

"min_cpu_platform": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"disk_config": {
Type: schema.TypeList,
Optional: true,
Expand Down
10 changes: 7 additions & 3 deletions google-beta/resource_dataproc_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"

"google.golang.org/api/dataproc/v1"
dataproc "google.golang.org/api/dataproc/v1beta2"
"google.golang.org/api/googleapi"
)

Expand Down Expand Up @@ -523,7 +523,7 @@ func testAccCheckDataprocClusterDestroy() resource.TestCheckFunc {
return err
}

_, err = config.clientDataproc.Projects.Regions.Clusters.Get(
_, err = config.clientDataprocBeta.Projects.Regions.Clusters.Get(
project, attributes["region"], rs.Primary.ID).Do()

if err != nil {
Expand Down Expand Up @@ -623,13 +623,15 @@ func validateDataprocCluster_withConfigOverrides(n string, cluster *dataproc.Clu
{"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.master_config.0.min_cpu_platform", "Intel Skylake", cluster.Config.MasterConfig.MinCpuPlatform},

{"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", "16", 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))},
{"cluster_config.0.worker_config.0.min_cpu_platform", "Intel Broadwell", cluster.Config.WorkerConfig.MinCpuPlatform},

{"cluster_config.0.preemptible_worker_config.0.num_instances", "1", strconv.Itoa(int(cluster.Config.SecondaryWorkerConfig.NumInstances))},
{"cluster_config.0.preemptible_worker_config.0.disk_config.0.boot_disk_size_gb", "17", strconv.Itoa(int(cluster.Config.SecondaryWorkerConfig.DiskConfig.BootDiskSizeGb))},
Expand Down Expand Up @@ -669,7 +671,7 @@ func testAccCheckDataprocClusterExists(n string, cluster *dataproc.Cluster) reso
return err
}

found, err := config.clientDataproc.Projects.Regions.Clusters.Get(
found, err := config.clientDataprocBeta.Projects.Regions.Clusters.Get(
project, rs.Primary.Attributes["region"], rs.Primary.ID).Do()
if err != nil {
return err
Expand Down Expand Up @@ -863,6 +865,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
boot_disk_type = "pd-ssd"
boot_disk_size_gb = 15
}
min_cpu_platform = "Intel Skylake"
}

worker_config {
Expand All @@ -873,6 +876,7 @@ resource "google_dataproc_cluster" "with_config_overrides" {
boot_disk_size_gb = 16
num_local_ssds = 1
}
min_cpu_platform = "Intel Broadwell"
}

preemptible_worker_config {
Expand Down