From 18d6446fcf9284ac5562d1693877df1c75cc28a2 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 13 Mar 2020 10:45:57 -0700 Subject: [PATCH] Revert "Placement policy support for Compute Instance (#3217)" (#3250) This reverts commit d7d347f224561e053231452081bbff2ce4c877f2. --- products/compute/api.yaml | 31 ------- products/compute/terraform.yaml | 5 -- .../resource_policy_placement_policy.tf.erb | 8 -- .../resources/resource_compute_instance.go | 13 --- .../tests/resource_compute_instance_test.go | 64 --------------- .../resource_compute_resource_policy_test.go | 80 ------------------- .../docs/r/compute_instance.html.markdown | 2 - 7 files changed, 203 deletions(-) delete mode 100644 templates/terraform/examples/resource_policy_placement_policy.tf.erb delete mode 100644 third_party/terraform/tests/resource_compute_resource_policy_test.go diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 067cf36219d..9c49dc56038 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -10481,8 +10481,6 @@ objects: which cannot be a dash. - !ruby/object:Api::Type::NestedObject name: 'snapshotSchedulePolicy' - conflicts: - - 'groupPlacementPolicy' description: | Policy for creating snapshots of persistent disks. properties: @@ -10624,35 +10622,6 @@ objects: - snapshot_schedule_policy.0.snapshot_properties.0.guest_flush description: | Whether to perform a 'guest aware' snapshot. - - !ruby/object:Api::Type::NestedObject - name: 'groupPlacementPolicy' - conflicts: - - 'snapshotSchedulePolicy' - description: | - Policy for creating snapshots of persistent disks. - properties: - - !ruby/object:Api::Type::Integer - name: 'vmCount' - at_least_one_of: - - group_placement_policy.0.vm_count - - group_placement_policy.0.availability_domain_count - description: | - Number of vms in this placement group - - !ruby/object:Api::Type::Integer - name: 'availabilityDomainCount' - at_least_one_of: - - group_placement_policy.0.vm_count - - group_placement_policy.0.availability_domain_count - description: | - The number of availability domains instances will be spread across. If two instances are in different - availability domain, they will not be put in the same low latency network - - !ruby/object:Api::Type::Enum - name: 'collocation' - description: | - Collocation specifies whether to place VMs inside the same availability domain on the same low-latency network. - Specify `COLLOCATED` to enable collocation. Can only be specified with `vm_count`. - values: - - :COLLOCATED - !ruby/object:Api::Resource name: 'Route' kind: 'compute#route' diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index cf88ed2a728..50e097cf2d2 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -1452,11 +1452,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_id: "bar" vars: name: "policy" - - !ruby/object:Provider::Terraform::Examples - name: "resource_policy_placement_policy" - primary_resource_id: "baz" - vars: - name: "policy" properties: region: !ruby/object:Overrides::Terraform::PropertyOverride required: false diff --git a/templates/terraform/examples/resource_policy_placement_policy.tf.erb b/templates/terraform/examples/resource_policy_placement_policy.tf.erb deleted file mode 100644 index d7b986612db..00000000000 --- a/templates/terraform/examples/resource_policy_placement_policy.tf.erb +++ /dev/null @@ -1,8 +0,0 @@ -resource "google_compute_resource_policy" "baz" { - name = "<%= ctx[:vars]['name'] %>" - region = "us-central1" - group_placement_policy { - vm_count = 2 - collocation = "COLLOCATED" - } -} diff --git a/third_party/terraform/resources/resource_compute_instance.go b/third_party/terraform/resources/resource_compute_instance.go index 2894aa71752..a43f5e260bb 100644 --- a/third_party/terraform/resources/resource_compute_instance.go +++ b/third_party/terraform/resources/resource_compute_instance.go @@ -593,15 +593,6 @@ func resourceComputeInstance() *schema.Resource { Optional: true, ForceNew: true, }, - - "resource_policies": { - Type: schema.TypeList, - Elem: &schema.Schema{Type: schema.TypeString}, - DiffSuppressFunc: compareSelfLinkRelativePaths, - Optional: true, - ForceNew: true, - MaxItems: 1, - }, }, CustomizeDiff: customdiff.All( customdiff.If( @@ -729,7 +720,6 @@ func expandComputeInstance(project string, d *schema.ResourceData, config *Confi ForceSendFields: []string{"CanIpForward", "DeletionProtection"}, ShieldedVmConfig: expandShieldedVmConfigs(d), DisplayDevice: expandDisplayDevice(d), - ResourcePolicies: convertStringArr(d.Get("resource_policies").([]interface{})), }, nil } @@ -993,9 +983,6 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error } } } - - d.Set("resource_policies", instance.ResourcePolicies) - // Remove nils from map in case there were disks in the config that were not present on read; // i.e. a disk was detached out of band ads := []map[string]interface{}{} diff --git a/third_party/terraform/tests/resource_compute_instance_test.go b/third_party/terraform/tests/resource_compute_instance_test.go index fe01dcf0a22..3e728d51120 100644 --- a/third_party/terraform/tests/resource_compute_instance_test.go +++ b/third_party/terraform/tests/resource_compute_instance_test.go @@ -1784,24 +1784,6 @@ func TestAccComputeInstance_updateTerminated_desiredStatusRunning_notAllowStoppi }) } -func TestAccComputeInstance_resourcePolicyCollocate(t *testing.T) { - t.Parallel() - - instanceName := fmt.Sprintf("terraform-test-%s", acctest.RandString(10)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeInstanceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccComputeInstance_resourcePolicyCollocate(instanceName), - }, - computeInstanceImportStep("us-central1-a", instanceName, []string{"allow_stopping_for_update"}), - }, - }) -} - func testAccCheckComputeInstanceUpdateMachineType(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -4536,49 +4518,3 @@ resource "google_compute_instance" "foobar" { } `, instance) } - -func testAccComputeInstance_resourcePolicyCollocate(instance string) string { - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" -} - -resource "google_compute_instance" "foobar" { - name = "%s" - machine_type = "c2-standard-4" - zone = "us-central1-f" - can_ip_forward = false - tags = ["foo", "bar"] - - //deletion_protection = false is implicit in this config due to default value - - boot_disk { - initialize_params { - image = data.google_compute_image.my_image.self_link - } - } - - network_interface { - network = "default" - } - - scheduling { - # Instances with resource policies do not support live migration. - on_host_maintenance = "TERMINATE" - } - - resource_policies = [google_compute_resource_policy.foo.self_link] -} - -resource "google_compute_resource_policy" "foo" { - name = "tf-test-policy-%s" - region = "us-central1" - group_placement_policy { - vm_count = 2 - collocation = "COLLOCATED" - } -} - -`, instance, acctest.RandString(10)) -} diff --git a/third_party/terraform/tests/resource_compute_resource_policy_test.go b/third_party/terraform/tests/resource_compute_resource_policy_test.go deleted file mode 100644 index 6c61ea0bdb1..00000000000 --- a/third_party/terraform/tests/resource_compute_resource_policy_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package google - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" -) - -func TestAccComputeResourcePolicy_attached(t *testing.T) { - t.Parallel() - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckComputeResourcePolicyDestroy, - Steps: []resource.TestStep{ - { - Config: testAccComputeResourcePolicy_attached(), - }, - { - ResourceName: "google_compute_resource_policy.foo", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccComputeResourcePolicy_attached() string { - return fmt.Sprintf(` -data "google_compute_image" "my_image" { - family = "debian-9" - project = "debian-cloud" -} - -resource "google_compute_instance" "foobar" { - name = "tf-test-%s" - machine_type = "n1-standard-1" - zone = "us-central1-a" - can_ip_forward = false - tags = ["foo", "bar"] - - //deletion_protection = false is implicit in this config due to default value - - boot_disk { - initialize_params { - image = data.google_compute_image.my_image.self_link - } - } - - network_interface { - network = "default" - } - - metadata = { - foo = "bar" - baz = "qux" - startup-script = "echo Hello" - } - - labels = { - my_key = "my_value" - my_other_key = "my_other_value" - } - - resource_policies = [google_compute_resource_policy.foo.self_link] -} - -resource "google_compute_resource_policy" "foo" { - name = "tf-test-policy-%s" - region = "us-central1" - group_placement_policy { - availability_domain_count = 2 - } -} - -`, acctest.RandString(10), acctest.RandString(10)) -} diff --git a/third_party/terraform/website/docs/r/compute_instance.html.markdown b/third_party/terraform/website/docs/r/compute_instance.html.markdown index 6c9e4e67cd6..093d4cd5f9e 100644 --- a/third_party/terraform/website/docs/r/compute_instance.html.markdown +++ b/third_party/terraform/website/docs/r/compute_instance.html.markdown @@ -164,8 +164,6 @@ The following arguments are supported: * `enable_display` - (Optional) Enable [Virtual Displays](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display#verify_display_driver) on this instance. **Note**: [`allow_stopping_for_update`](#allow_stopping_for_update) must be set to true or your instance must have a `desired_status` of `TERMINATED` in order to update this field. -* `resource_policies` (Optional) -- A list of short names or self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. - ---