Skip to content

Commit

Permalink
Add support for visible_core_count for google_compute_instance resour…
Browse files Browse the repository at this point in the history
…ce (#6414)

* add support for threads per core

* adding missing comma

* add support for threads per core

* guard changes with beta flag

* fixing typo

* fixing value

* guarding changes with flags

* annoting doc attribute with beta tag

* annoting doc attribute with beta tag

* missing comma

* adding guards for beta params

* adding guards for beta params

* incoprated comments

* incoprated comments
  • Loading branch information
prateek2408 authored Aug 26, 2022
1 parent cb8f65e commit 193287d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,14 @@ func resourceComputeInstance() *schema.Resource {
AtLeastOneOf: []string{"advanced_machine_features.0.enable_nested_virtualization","advanced_machine_features.0.threads_per_core"},
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.`,
},
<% unless version == 'ga' -%>
"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"},
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.`,
},
<% end -%>
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,14 @@ func resourceComputeInstanceTemplate() *schema.Resource {
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.`,
},
<% unless version == 'ga' -%>
"visible_core_count": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
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.`,
},
<% end -%>
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,9 @@ resource "google_compute_instance_template" "foobar" {
advanced_machine_features {
threads_per_core = 1
enable_nested_virtualization = true
<% unless version == "ga" -%>
visible_core_count = 1
<% end -%>
}

scheduling {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4755,6 +4755,9 @@ resource "google_compute_instance" "foobar" {
advanced_machine_features {
threads_per_core = 1
enable_nested_virtualization = true
<% unless version == 'ga' -%>
visible_core_count = 1
<% end -%>
}
allow_stopping_for_update = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ func expandAdvancedMachineFeatures(d TerraformResourceData) *compute.AdvancedMac
return &compute.AdvancedMachineFeatures{
EnableNestedVirtualization: d.Get(prefix + ".enable_nested_virtualization").(bool),
ThreadsPerCore: int64(d.Get(prefix + ".threads_per_core").(int)),
<% unless version == 'ga' -%>
VisibleCoreCount: int64(d.Get(prefix + ".visible_core_count").(int)),
<% end -%>
}
}

Expand All @@ -411,6 +414,9 @@ func flattenAdvancedMachineFeatures(AdvancedMachineFeatures *compute.AdvancedMac
return []map[string]interface{}{{
"enable_nested_virtualization": AdvancedMachineFeatures.EnableNestedVirtualization,
"threads_per_core": AdvancedMachineFeatures.ThreadsPerCore,
<% unless version == 'ga' -%>
"visible_core_count": AdvancedMachineFeatures.VisibleCoreCount,
<% end -%>
}}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ specified, then this instance will have no external IPv6 Internet access. Struct

* `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.

* `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).

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

* `type` - (Required) The type of reservation from which this instance can consume resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,9 @@ The `specific_reservation` block supports:

* `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, [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).

## Attributes Reference

Expand Down

0 comments on commit 193287d

Please sign in to comment.