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

compute: added support for advanced_machine_features.turbo_mode #8551

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
3 changes: 3 additions & 0 deletions .changelog/12148.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added support for `advanced_machine_features.turbo_mode` to `google_compute_instance`, `google_compute_instance_template`, and `google_compute_region_instance_template`
```
2 changes: 2 additions & 0 deletions google-beta/services/compute/compute_instance_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ func expandAdvancedMachineFeatures(d tpgresource.TerraformResourceData) *compute
return &compute.AdvancedMachineFeatures{
EnableNestedVirtualization: d.Get(prefix + ".enable_nested_virtualization").(bool),
ThreadsPerCore: int64(d.Get(prefix + ".threads_per_core").(int)),
TurboMode: d.Get(prefix + ".turbo_mode").(string),
VisibleCoreCount: int64(d.Get(prefix + ".visible_core_count").(int)),
}
}
Expand All @@ -645,6 +646,7 @@ func flattenAdvancedMachineFeatures(AdvancedMachineFeatures *compute.AdvancedMac
return []map[string]interface{}{{
"enable_nested_virtualization": AdvancedMachineFeatures.EnableNestedVirtualization,
"threads_per_core": AdvancedMachineFeatures.ThreadsPerCore,
"turbo_mode": AdvancedMachineFeatures.TurboMode,
"visible_core_count": AdvancedMachineFeatures.VisibleCoreCount,
}}
}
Expand Down
20 changes: 17 additions & 3 deletions google-beta/services/compute/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func IpCidrRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
}

var (
advancedMachineFeaturesKeys = []string{
"advanced_machine_features.0.enable_nested_virtualization",
"advanced_machine_features.0.threads_per_core",
"advanced_machine_features.0.turbo_mode",
"advanced_machine_features.0.visible_core_count",
}

bootDiskKeys = []string{
"boot_disk.0.auto_delete",
"boot_disk.0.device_name",
Expand Down Expand Up @@ -1075,19 +1082,26 @@ be from 0 to 999,999,999 inclusive.`,
"enable_nested_virtualization": {
Type: schema.TypeBool,
Optional: true,
AtLeastOneOf: []string{"advanced_machine_features.0.enable_nested_virtualization", "advanced_machine_features.0.threads_per_core"},
AtLeastOneOf: advancedMachineFeaturesKeys,
Description: `Whether to enable nested virtualization or not.`,
},
"threads_per_core": {
Type: schema.TypeInt,
Optional: true,
AtLeastOneOf: []string{"advanced_machine_features.0.enable_nested_virtualization", "advanced_machine_features.0.threads_per_core"},
AtLeastOneOf: advancedMachineFeaturesKeys,
Description: `The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed.`,
},
"turbo_mode": {
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: advancedMachineFeaturesKeys,
Description: `Turbo frequency mode to use for the instance. Currently supported modes is "ALL_CORE_MAX".`,
ValidateFunc: validation.StringInSlice([]string{"ALL_CORE_MAX"}, false),
},
"visible_core_count": {
Type: schema.TypeInt,
Optional: true,
AtLeastOneOf: []string{"advanced_machine_features.0.enable_nested_virtualization", "advanced_machine_features.0.threads_per_core", "advanced_machine_features.0.visible_core_count"},
AtLeastOneOf: advancedMachineFeaturesKeys,
Description: `The number of physical cores to expose to an instance. Multiply by the number of threads per core to compute the total number of virtual CPUs to expose to the instance. If unset, the number of cores is inferred from the instance\'s nominal CPU count and the underlying platform\'s SMT width.`,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,12 @@ be from 0 to 999,999,999 inclusive.`,
ForceNew: true,
Description: `The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed.`,
},
"turbo_mode": {
Type: schema.TypeString,
Optional: true,
Description: `Turbo frequency mode to use for the instance. Currently supported modes is "ALL_CORE_MAX".`,
ValidateFunc: validation.StringInSlice([]string{"ALL_CORE_MAX"}, false),
},
"visible_core_count": {
Type: schema.TypeInt,
Optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3721,11 +3721,11 @@ data "google_compute_image" "my_image" {

resource "google_compute_instance_template" "foobar" {
name = "tf-test-instance-template-%s"
machine_type = "n2-standard-2" // Nested Virt isn't supported on E2 and N2Ds https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions and https://cloud.google.com/compute/docs/instances/disabling-smt#limitations
machine_type = "c4-standard-2"

disk {
source_image = data.google_compute_image.my_image.self_link
auto_delete = true
auto_delete = true
boot = true
}

Expand All @@ -3734,13 +3734,14 @@ resource "google_compute_instance_template" "foobar" {
}

advanced_machine_features {
threads_per_core = 1
enable_nested_virtualization = true
visible_core_count = 1
enable_nested_virtualization = true
threads_per_core = 1
turbo_mode = "ALL_CORE_MAX"
visible_core_count = 1
}

scheduling {
on_host_maintenance = "TERMINATE"
on_host_maintenance = "TERMINATE"
}

}
Expand Down
11 changes: 6 additions & 5 deletions google-beta/services/compute/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7124,7 +7124,7 @@ data "google_compute_image" "my_image" {

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-2" // Nested Virt isn't supported on E2 and N2Ds https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions and https://cloud.google.com/compute/docs/instances/disabling-smt#limitations
machine_type = "c4-standard-2"
zone = "us-central1-a"

boot_disk {
Expand Down Expand Up @@ -7152,7 +7152,7 @@ data "google_compute_image" "my_image" {

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-2" // Nested Virt isn't supported on E2 and N2Ds https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions and https://cloud.google.com/compute/docs/instances/disabling-smt#limitations
machine_type = "c4-standard-2"
zone = "us-central1-a"

boot_disk {
Expand All @@ -7165,9 +7165,10 @@ resource "google_compute_instance" "foobar" {
network = "default"
}
advanced_machine_features {
threads_per_core = 1
enable_nested_virtualization = true
visible_core_count = 1
enable_nested_virtualization = true
threads_per_core = 1
turbo_mode = "ALL_CORE_MAX"
visible_core_count = 1
}
allow_stopping_for_update = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ be from 0 to 999,999,999 inclusive.`,
ForceNew: true,
Description: `The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed.`,
},
"turbo_mode": {
Type: schema.TypeString,
Optional: true,
Description: `Turbo frequency mode to use for the instance. Currently supported modes is "ALL_CORE_MAX".`,
ValidateFunc: validation.StringInSlice([]string{"ALL_CORE_MAX"}, false),
},
"visible_core_count": {
Type: schema.TypeInt,
Optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3120,8 +3120,8 @@ data "google_compute_image" "my_image" {

resource "google_compute_region_instance_template" "foobar" {
name = "tf-test-instance-template-%s"
region = "us-central1"
machine_type = "n2-standard-2" // Nested Virt isn't supported on E2 and N2Ds https://cloud.google.com/compute/docs/instances/nested-virtualization/overview#restrictions and https://cloud.google.com/compute/docs/instances/disabling-smt#limitations
region = "us-central1"
machine_type = "c2-standard-2"

disk {
source_image = data.google_compute_image.my_image.self_link
Expand All @@ -3134,9 +3134,10 @@ resource "google_compute_region_instance_template" "foobar" {
}

advanced_machine_features {
threads_per_core = 1
enable_nested_virtualization = true
visible_core_count = 1
threads_per_core = 1
turbo_mode = "ALL_CORE_MAX"
visible_core_count = 1
}

scheduling {
Expand Down
8 changes: 5 additions & 3 deletions website/docs/r/compute_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,13 @@ specified, then this instance will have no external IPv6 Internet access. Struct

<a name="nested_advanced_machine_features"></a>The `advanced_machine_features` block supports:

* `enable_nested_virtualization` (Optional) Defines whether the instance should have [nested virtualization](#on_host_maintenance) enabled. Defaults to false.
* `enable_nested_virtualization` - (Optional) Defines whether the instance should have [nested virtualization](#on_host_maintenance) enabled. Defaults to false.

* `threads_per_core` (Optional) he number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1.
* `threads_per_core` - (Optional) The number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1.

* `visible_core_count` (Optional) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores).
* `turbo_mode` - (Optional) Turbo frequency mode to use for the instance. Supported modes are currently either `ALL_CORE_MAX` or unset (default).

* `visible_core_count` - (Optional) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores).

<a name="nested_reservation_affinity"></a>The `reservation_affinity` block supports:

Expand Down
8 changes: 5 additions & 3 deletions website/docs/r/compute_instance_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,13 @@ The `specific_reservation` block supports:

<a name="nested_advanced_machine_features"></a>The `advanced_machine_features` block supports:

* `enable_nested_virtualization` (Optional) Defines whether the instance should have [nested virtualization](#on_host_maintenance) enabled. Defaults to false.
* `enable_nested_virtualization` - (Optional) Defines whether the instance should have [nested virtualization](#on_host_maintenance) enabled. Defaults to false.

* `threads_per_core` (Optional) The number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1.
* `threads_per_core` - (Optional) The number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1.

* `visible_core_count` (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores).
* `turbo_mode` - (Optional) Turbo frequency mode to use for the instance. Supported modes are currently either `ALL_CORE_MAX` or unset (default).

* `visible_core_count` - (Optional) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores).

## Attributes Reference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,13 @@ The `specific_reservation` block supports:

<a name="nested_advanced_machine_features"></a>The `advanced_machine_features` block supports:

* `enable_nested_virtualization` (Optional) Defines whether the instance should have [nested virtualization](#on_host_maintenance) enabled. Defaults to false.
* `enable_nested_virtualization` - (Optional) Defines whether the instance should have [nested virtualization](#on_host_maintenance) enabled. Defaults to false.

* `threads_per_core` (Optional) The number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1.
* `threads_per_core` - (Optional) The number of threads per physical core. To disable [simultaneous multithreading (SMT)](https://cloud.google.com/compute/docs/instances/disabling-smt) set this to 1.

* `visible_core_count` (Optional, ) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores).
* `turbo_mode` - (Optional) Turbo frequency mode to use for the instance. Supported modes are currently either `ALL_CORE_MAX` or unset (default).

* `visible_core_count` - (Optional) The number of physical cores to expose to an instance. [visible cores info (VC)](https://cloud.google.com/compute/docs/instances/customize-visible-cores).

## Attributes Reference

Expand Down