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

[Compute_Disk] - Add beta multi-writer support #3911

Merged
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
5 changes: 5 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,11 @@ objects:
resource: 'ResourcePolicy'
imports: 'selfLink'
description: 'A resource policy applied to this disk for automatic snapshot creations.'
- !ruby/object:Api::Type::Boolean
name: 'multiWriter'
description: |
Indicates whether or not the disk can be read/write attached to more than one instance.
min_version: beta
- !ruby/object:Api::Resource
name: 'Firewall'
kind: 'compute#firewall'
Expand Down
68 changes: 68 additions & 0 deletions third_party/terraform/tests/resource_compute_disk_test.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,29 @@ func TestAccComputeDisk_interface(t *testing.T) {
}
<% end -%>

<% unless version == 'ga' -%>
func TestAccComputeDisk_multiWriter(t *testing.T) {
t.Parallel()
instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
diskName := fmt.Sprintf("tf-testd-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccComputeDisk_multiWriter(instanceName, diskName, true),
},
{
ResourceName: "google_compute_disk.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
<% end -%>

func testAccCheckComputeDiskExists(t *testing.T, n, p string, disk *compute.Disk) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -816,3 +839,48 @@ resource "google_compute_disk" "foobar" {
`, diskName)
}
<% end -%>

<% unless version == 'ga' -%>
func testAccComputeDisk_multiWriter(instance string, diskName string, enableMultiwriter bool) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_disk" "foobar" {
name = "%s"
size = 10
type = "pd-ssd"
zone = "us-central1-a"
multi_writer = %t
}

resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "n2-standard-2"
zone = "us-central1-a"
can_ip_forward = false
tags = ["foo", "bar"]

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

attached_disk {
source = google_compute_disk.foobar.name
}

network_interface {
network = "default"
}

metadata = {
foo = "bar"
}
}
`, diskName, enableMultiwriter, instance)
}
<% end -%>