Skip to content

Commit 973809a

Browse files
Add host_error_timeout_seconds field to compute_instance on beta provider (#11652)
Co-authored-by: Nick Elliot <[email protected]>
1 parent 6b7012d commit 973809a

12 files changed

+201
-2
lines changed

mmv1/third_party/terraform/services/compute/compute_instance_helpers.go.erb

+13
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ func expandScheduling(v interface{}) (*compute.Scheduling, error) {
165165
scheduling.ForceSendFields = append(scheduling.ForceSendFields, "OnInstanceStopAction")
166166
}
167167
<% unless version == 'ga' -%>
168+
if v, ok := original["host_error_timeout_seconds"]; ok {
169+
scheduling.HostErrorTimeoutSeconds = int64(v.(int))
170+
}
171+
168172
if v, ok := original["maintenance_interval"]; ok {
169173
scheduling.MaintenanceInterval = v.(string)
170174
}
@@ -287,6 +291,10 @@ func flattenScheduling(resp *compute.Scheduling) []map[string]interface{} {
287291
}
288292

289293
<% unless version == 'ga' -%>
294+
if resp.HostErrorTimeoutSeconds != 0 {
295+
schedulingMap["host_error_timeout_seconds"] = resp.HostErrorTimeoutSeconds
296+
}
297+
290298
if resp.MaintenanceInterval != "" {
291299
schedulingMap["maintenance_interval"] = resp.MaintenanceInterval
292300
}
@@ -737,6 +745,11 @@ func schedulingHasChangeWithoutReboot(d *schema.ResourceData) bool {
737745
if oScheduling["instance_termination_action"] != newScheduling["instance_termination_action"] {
738746
return true
739747
}
748+
<% unless version == 'ga' -%>
749+
if oScheduling["host_error_timeout_seconds"] != newScheduling["host_error_timeout_seconds"] {
750+
return true
751+
}
752+
<% end -%>
740753

741754
return false
742755
}

mmv1/third_party/terraform/services/compute/resource_compute_instance.go.erb

+7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ var (
8989
"scheduling.0.on_instance_stop_action",
9090
<% unless version == 'ga' -%>
9191
"scheduling.0.maintenance_interval",
92+
"scheduling.0.host_error_timeout_seconds",
9293
<% end -%>
9394
"scheduling.0.local_ssd_recovery_timeout",
9495
}
@@ -932,6 +933,12 @@ be from 0 to 999,999,999 inclusive.`,
932933
},
933934
},
934935
<% unless version == 'ga' -%>
936+
"host_error_timeout_seconds": {
937+
Type: schema.TypeInt,
938+
Optional: true,
939+
Description: `Specify the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.`,
940+
},
941+
935942
"maintenance_interval": {
936943
Type: schema.TypeString,
937944
Optional: true,

mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.erb

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939
"scheduling.0.on_instance_stop_action",
4040
<% unless version == 'ga' -%>
4141
"scheduling.0.maintenance_interval",
42+
"scheduling.0.host_error_timeout_seconds",
4243
<% end -%>
4344
"scheduling.0.local_ssd_recovery_timeout",
4445
}
@@ -761,6 +762,13 @@ be from 0 to 999,999,999 inclusive.`,
761762
},
762763
},
763764
<% unless version == 'ga' -%>
765+
"host_error_timeout_seconds": {
766+
Type: schema.TypeInt,
767+
Optional: true,
768+
ForceNew: true,
769+
Description: `Specify the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.`,
770+
},
771+
764772
"maintenance_interval" : {
765773
Type: schema.TypeString,
766774
Optional: true,

mmv1/third_party/terraform/services/compute/resource_compute_instance_template_test.go.erb

+81
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,44 @@ func TestAccComputeInstanceTemplate_maintenance_interval(t *testing.T) {
158158
}
159159
<% end -%>
160160

161+
<% unless version == "ga" -%>
162+
func TestAccComputeInstanceTemplate_hostErrorTimeoutSeconds(t *testing.T) {
163+
t.Parallel()
164+
165+
var instanceTemplate compute.InstanceTemplate
166+
167+
acctest.VcrTest(t, resource.TestCase{
168+
PreCheck: func() { acctest.AccTestPreCheck(t) },
169+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
170+
CheckDestroy: testAccCheckComputeInstanceTemplateDestroyProducer(t),
171+
Steps: []resource.TestStep{
172+
{
173+
Config: testAccComputeInstanceTemplate_hostErrorTimeoutSeconds(acctest.RandString(t, 10)),
174+
Check: resource.ComposeTestCheckFunc(
175+
testAccCheckComputeInstanceTemplateExists(
176+
t, "google_compute_instance_template.foobar", &instanceTemplate),
177+
resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "scheduling.0.host_error_timeout_seconds", "120"),
178+
),
179+
},
180+
{
181+
ResourceName: "google_compute_instance_template.foobar",
182+
ImportState: true,
183+
ImportStateVerify: true,
184+
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
185+
},
186+
{
187+
Config: testAccComputeInstanceTemplate_basic(acctest.RandString(t, 10)),
188+
Check: resource.ComposeTestCheckFunc(
189+
testAccCheckComputeInstanceTemplateExists(
190+
t, "google_compute_instance_template.foobar", &instanceTemplate),
191+
resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "scheduling.0.host_error_timeout_seconds", "0"),
192+
),
193+
},
194+
},
195+
})
196+
}
197+
<% end -%>
198+
161199
func TestAccComputeInstanceTemplate_IP(t *testing.T) {
162200
t.Parallel()
163201

@@ -2391,6 +2429,49 @@ resource "google_compute_instance_template" "foobar" {
23912429
}
23922430
`, suffix)
23932431
}
2432+
2433+
func testAccComputeInstanceTemplate_hostErrorTimeoutSeconds(suffix string) string {
2434+
return fmt.Sprintf(`
2435+
data "google_compute_image" "my_image" {
2436+
family = "debian-11"
2437+
project = "debian-cloud"
2438+
}
2439+
2440+
resource "google_compute_instance_template" "foobar" {
2441+
name = "tf-test-instance-template-%s"
2442+
machine_type = "e2-medium"
2443+
can_ip_forward = false
2444+
tags = ["foo", "bar"]
2445+
2446+
disk {
2447+
source_image = data.google_compute_image.my_image.self_link
2448+
auto_delete = true
2449+
boot = true
2450+
}
2451+
2452+
network_interface {
2453+
network = "default"
2454+
}
2455+
2456+
scheduling {
2457+
host_error_timeout_seconds = 120
2458+
}
2459+
2460+
metadata = {
2461+
foo = "bar"
2462+
}
2463+
2464+
service_account {
2465+
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
2466+
}
2467+
2468+
labels = {
2469+
my_label = "foobar"
2470+
}
2471+
}
2472+
`, suffix)
2473+
}
2474+
23942475
<% end -%>
23952476

23962477
func testAccComputeInstanceTemplate_ip(suffix string) string {

mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.erb

+72
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,49 @@ func TestAccComputeInstance_reservationAffinities(t *testing.T) {
14831483
})
14841484
}
14851485

1486+
<% unless version == 'ga' -%>
1487+
func TestAccComputeInstance_hostErrorTimeoutSecconds(t *testing.T) {
1488+
t.Parallel()
1489+
1490+
var instance compute.Instance
1491+
context_1 := map[string]interface{}{
1492+
"instance_name": fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)),
1493+
"zone": "us-central1-a",
1494+
"host_error_timeout_sec": 90,
1495+
}
1496+
1497+
context_2 := map[string]interface{}{
1498+
"instance_name": context_1["instance_name"],
1499+
"zone": context_1["zone"],
1500+
"host_error_timeout_sec": 120,
1501+
}
1502+
1503+
acctest.VcrTest(t, resource.TestCase{
1504+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1505+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1506+
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
1507+
Steps: []resource.TestStep{
1508+
{
1509+
Config: testAccComputeInstance_hostErrorTimeoutSeconds(context_1),
1510+
Check: resource.ComposeTestCheckFunc(
1511+
testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
1512+
resource.TestCheckResourceAttr("google_compute_instance.foobar", "scheduling.0.host_error_timeout_seconds", "90"),
1513+
),
1514+
},
1515+
computeInstanceImportStep(context_1["zone"].(string), context_1["instance_name"].(string), []string{}),
1516+
{
1517+
Config: testAccComputeInstance_hostErrorTimeoutSeconds(context_2),
1518+
Check: resource.ComposeTestCheckFunc(
1519+
testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
1520+
resource.TestCheckResourceAttr("google_compute_instance.foobar", "scheduling.0.host_error_timeout_seconds", "120"),
1521+
),
1522+
},
1523+
computeInstanceImportStep(context_2["zone"].(string), context_2["instance_name"].(string), []string{}),
1524+
},
1525+
})
1526+
}
1527+
<% end -%>
1528+
14861529
func TestAccComputeInstance_subnet_auto(t *testing.T) {
14871530
t.Parallel()
14881531

@@ -8128,6 +8171,35 @@ resource "google_compute_instance" "foobar" {
81288171
}`, instanceName)
81298172
}
81308173

8174+
<% unless version == 'ga' -%>
8175+
func testAccComputeInstance_hostErrorTimeoutSeconds(context map[string]interface{}) string {
8176+
return acctest.Nprintf(`
8177+
data "google_compute_image" "my_image" {
8178+
family = "debian-12"
8179+
project = "debian-cloud"
8180+
}
8181+
8182+
resource "google_compute_instance" "foobar" {
8183+
name = "%{instance_name}"
8184+
zone = "%{zone}"
8185+
machine_type = "n2-standard-2"
8186+
8187+
boot_disk {
8188+
initialize_params {
8189+
image = data.google_compute_image.my_image.self_link
8190+
}
8191+
}
8192+
8193+
network_interface {
8194+
network = "default"
8195+
}
8196+
scheduling {
8197+
host_error_timeout_seconds = %{host_error_timeout_sec}
8198+
}
8199+
}`, context)
8200+
}
8201+
<% end -%>
8202+
81318203
func testAccComputeInstance_shieldedVmConfig(instance string, enableSecureBoot bool, enableVtpm bool, enableIntegrityMonitoring bool) string {
81328204
return fmt.Sprintf(`
81338205
data "google_compute_image" "my_image" {

mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.erb

+7
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,13 @@ be from 0 to 999,999,999 inclusive.`,
721721
},
722722
},
723723
<% unless version == 'ga' -%>
724+
"host_error_timeout_seconds": {
725+
Type: schema.TypeInt,
726+
Optional: true,
727+
ForceNew: true,
728+
Description: `Specify the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.`,
729+
},
730+
724731
"maintenance_interval" : {
725732
Type: schema.TypeString,
726733
Optional: true,

mmv1/third_party/terraform/website/docs/d/compute_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ The following arguments are supported:
188188

189189
<a name="nested_scheduling"></a>The `scheduling` block supports:
190190

191+
* `host_error_timeout_seconds` - [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Time in seconds for host error detection.
192+
191193
* `preemptible` - Whether the instance is preemptible.
192194

193195
* `on_host_maintenance` - Describes maintenance behavior for the

mmv1/third_party/terraform/website/docs/d/compute_instance_template.html.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ The `disk_encryption_key` block supports:
276276
groups will use as host systems. Read more on sole-tenant node creation
277277
[here](https://cloud.google.com/compute/docs/nodes/create-nodes).
278278
Structure [documented below](#nested_node_affinities).
279-
279+
280+
* `host_error_timeout_seconds` - [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Time in seconds for host error detection.
281+
280282
* `provisioning_model` - Describe the type of preemptible VM.
281283

282284
* `instance_termination_action` - Describe the type of termination action for `SPOT` VM. Can be `STOP` or `DELETE`. Read more on [here](https://cloud.google.com/compute/docs/instances/create-use-spot)

mmv1/third_party/terraform/website/docs/d/compute_region_instance_template.html.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ The `disk_encryption_key` block supports:
260260
groups will use as host systems. Read more on sole-tenant node creation
261261
[here](https://cloud.google.com/compute/docs/nodes/create-nodes).
262262
Structure [documented below](#nested_node_affinities).
263-
263+
264+
* `host_error_timeout_seconds` - [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Time in seconds for host error detection.
265+
264266
* `provisioning_model` - Describe the type of preemptible VM.
265267

266268
* `instance_termination_action` - Describe the type of termination action for `SPOT` VM. Can be `STOP` or `DELETE`. Read more on [here](https://cloud.google.com/compute/docs/instances/create-use-spot)

mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ specified, then this instance will have no external IPv6 Internet access. Struct
493493

494494
* `on_instance_stop_action` - (Optional) Specifies the action to be performed when the instance is terminated using `max_run_duration` and `STOP` `instance_termination_action`. Only support `true` `discard_local_ssd` at this point. Structure is [documented below](#nested_on_instance_stop_action).
495495

496+
* `host_error_timeout_seconds` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.
496497

497498
* `maintenance_interval` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the frequency of planned maintenance events. The accepted values are: `PERIODIC`.
498499

mmv1/third_party/terraform/website/docs/r/compute_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ specified, then this instance will have no external IPv6 Internet access. Struct
641641

642642
* `on_instance_stop_action` - (Optional) Specifies the action to be performed when the instance is terminated using `max_run_duration` and `STOP` `instance_termination_action`. Only support `true` `discard_local_ssd` at this point. Structure is [documented below](#nested_on_instance_stop_action).
643643

644+
* `host_error_timeout_seconds` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.
645+
644646
* `maintenance_interval` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the frequency of planned maintenance events. The accepted values are: `PERIODIC`.
645647

646648
* `local_ssd_recovery_timeout` - (Optional) (https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the maximum amount of time a Local Ssd Vm should wait while recovery of the Local Ssd state is attempted. Its value should be in between 0 and 168 hours with hour granularity and the default value being 1 hour. Structure is [documented below](#nested_local_ssd_recovery_timeout).

mmv1/third_party/terraform/website/docs/r/compute_region_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ specified, then this instance will have no external IPv6 Internet access. Struct
603603

604604
* `instance_termination_action` - (Optional) Describe the type of termination action for `SPOT` VM. Can be `STOP` or `DELETE`. Read more on [here](https://cloud.google.com/compute/docs/instances/create-use-spot)
605605

606+
* `host_error_timeout_seconds` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the time in seconds for host error detection, the value must be within the range of [90, 330] with the increment of 30, if unset, the default behavior of host error recovery will be used.
607+
606608
* `max_run_duration` - (Optional) The duration of the instance. Instance will run and be terminated after then, the termination action could be defined in `instance_termination_action`. Only support `DELETE` `instance_termination_action` at this point. Structure is [documented below](#nested_max_run_duration).
607609

608610
<a name="nested_max_run_duration"></a>The `max_run_duration` block supports:

0 commit comments

Comments
 (0)