Skip to content

Commit 7b6479a

Browse files
committed
Revert "Allow updating guest accelerator count to 0 on compute_instance (#15410) (#10902)"
This reverts commit 7ff0223.
1 parent b87df26 commit 7b6479a

File tree

3 files changed

+3
-26
lines changed

3 files changed

+3
-26
lines changed

.changelog/15410.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

google-beta/services/compute/resource_compute_instance.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,23 +3343,12 @@ func suppressEmptyGuestAcceleratorDiff(_ context.Context, d *schema.ResourceDiff
33433343
return nil
33443344
}
33453345

3346-
// Check if old had a non-zero count
3347-
if len(old) > 0 {
3348-
if apiAccel, ok := old[0].(map[string]interface{}); ok {
3349-
if oldCount, ok := apiAccel["count"].(int); ok && oldCount != 0 {
3350-
// Old count wasn't 0, so don't clear the diff
3351-
return nil
3352-
}
3353-
}
3354-
}
3355-
3356-
// Check new accelerator configuration
3357-
configAccel, ok := new[0].(map[string]interface{})
3346+
firstAccel, ok := new[0].(map[string]interface{})
33583347
if !ok {
33593348
return fmt.Errorf("Unable to type assert guest accelerator")
33603349
}
33613350

3362-
if configAccel["count"].(int) == 0 {
3351+
if firstAccel["count"].(int) == 0 {
33633352
if err := d.Clear("guest_accelerator"); err != nil {
33643353
return err
33653354
}

google-beta/services/compute/resource_compute_instance_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,16 +2510,10 @@ func TestAccComputeInstance_guestAccelerator(t *testing.T) {
25102510
testAccCheckComputeInstanceHasGuestAccelerator(&instance, "nvidia-tesla-t4", 1),
25112511
),
25122512
},
2513-
{
2514-
Config: testAccComputeInstance_guestAccelerator(instanceName, 0),
2515-
Check: resource.ComposeTestCheckFunc(
2516-
testAccCheckComputeInstanceExists(t, "google_compute_instance.foobar", &instance),
2517-
testAccCheckComputeInstanceHasGuestAccelerator(&instance, "nvidia-tesla-t4", 0),
2518-
),
2519-
},
25202513
computeInstanceImportStep("us-east1-d", instanceName, []string{"metadata.baz", "metadata.foo"}),
25212514
},
25222515
})
2516+
25232517
}
25242518

25252519
func TestAccComputeInstance_guestAcceleratorSkip(t *testing.T) {
@@ -5833,9 +5827,6 @@ func testAccCheckComputeInstanceHasMultiNic(instance *compute.Instance) resource
58335827
func testAccCheckComputeInstanceHasGuestAccelerator(instance *compute.Instance, acceleratorType string, acceleratorCount int64) resource.TestCheckFunc {
58345828
return func(s *terraform.State) error {
58355829
if len(instance.GuestAccelerators) != 1 {
5836-
if int(acceleratorCount) == 0 && len(instance.GuestAccelerators) == 0 {
5837-
return nil
5838-
}
58395830
return fmt.Errorf("Expected only one guest accelerator")
58405831
}
58415832

0 commit comments

Comments
 (0)