Skip to content

Commit

Permalink
Prepare removal of guest_accelerator ConfigModeAttr (#11425)
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn authored Aug 12, 2024
1 parent 5043710 commit 9cf5fda
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,20 @@ func TestAccComputeInstance_guestAcceleratorSkip(t *testing.T) {
testAccCheckComputeInstanceLacksGuestAccelerator(&instance),
),
},
// Recreate with guest_accelerator = []
{
Config: testAccComputeInstance_guestAcceleratorEmptyBlock(instanceName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
testAccCheckComputeInstanceLacksGuestAccelerator(&instance),
),
},
// Check that count = 0 is the same as empty block []
{
Config: testAccComputeInstance_guestAccelerator(instanceName, 0),
ExpectNonEmptyPlan: false,
PlanOnly: true,
},
},
})

Expand Down Expand Up @@ -7098,6 +7112,38 @@ resource "google_compute_instance" "foobar" {
`, instance, count)
}

func testAccComputeInstance_guestAcceleratorEmptyBlock(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-11"
project = "debian-cloud"
}

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n1-standard-1" // can't be e2 because of guest_accelerator
zone = "us-east1-d"

boot_disk {
initialize_params {
image = data.google_compute_image.my_image.self_link
}
}

network_interface {
network = "default"
}

scheduling {
# Instances with guest accelerators do not support live migration.
on_host_maintenance = "TERMINATE"
}

guest_accelerator = []
}
`, instance)
}

func testAccComputeInstance_minCpuPlatform(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,12 @@ func TestAccContainerNodePool_012_ConfigModeAttr(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
// Test guest_accelerator.count = 0 is the same as guest_accelerator = []
Config: testAccContainerNodePool_EmptyGuestAccelerator(cluster, np, networkName, subnetworkName),
ExpectNonEmptyPlan: false,
PlanOnly: true,
},
},
})
}
Expand Down Expand Up @@ -3800,6 +3806,7 @@ resource "google_container_node_pool" "np" {

node_config {
guest_accelerator = []
machine_type = "n1-highmem-4"
}
}
`, cluster, networkName, subnetworkName, np)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ Removed in favor of field `settings.ip_configuration.ssl_mode`.

An empty value means the setting should be cleared.

## Resources: `google_container_cluster`, `google_container_node_pool`, and `google_compute_instance`

### `guest_accelerator = []` is no longer valid configuration

To explicitly set an empty list of objects, set `guest_accelerator.count = 0`.

Previously, to explicitly set `guest_accelerator` as an empty list of objects, the specific configuration `guest_accelerator = []` was necessary.
This was to maintain compatability in behavior between Terraform versions 0.11 and 0.12 using a special setting ["attributes as blocks"](https://developer.hashicorp.com/terraform/language/attr-as-blocks).
This special setting causes other breakages so it is now removed, with setting `guest_accelerator.count = 0` available as an alternative form of empty `guest_accelerator` object.

### `guest_accelerator.gpu_driver_installation_config = []` and `guest_accelerator.gpu_sharing_config = []` are no longer valid configuration

These were never intended to be set this way. Removing the fields from configuration should not produce a diff.

## Resource: `google_domain`

### Domain deletion now prevented by default with `deletion_protection`
Expand Down

0 comments on commit 9cf5fda

Please sign in to comment.