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

Prepare removal of guest_accelerator ConfigModeAttr #11425

Merged
merged 1 commit into from
Aug 12, 2024
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
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
Loading