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

Network queue count support #10571

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
3 changes: 3 additions & 0 deletions .changelog/5438.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added support for `queue_count` to `google_compute_instance.network_interface` and `google_compute_instance_template.network_interface`
```
2 changes: 2 additions & 0 deletions google/compute_instance_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func flattenNetworkInterfaces(d *schema.ResourceData, config *Config, networkInt
"nic_type": iface.NicType,
"stack_type": iface.StackType,
"ipv6_access_config": flattenIpv6AccessConfigs(iface.Ipv6AccessConfigs),
"queue_count": iface.QueueCount,
}
// Instance template interfaces never have names, so they're absent
// in the instance template network_interface schema. We want to use the
Expand Down Expand Up @@ -279,6 +280,7 @@ func expandNetworkInterfaces(d TerraformResourceData, config *Config) ([]*comput
AliasIpRanges: expandAliasIpRanges(data["alias_ip_range"].([]interface{})),
NicType: data["nic_type"].(string),
StackType: data["stack_type"].(string),
QueueCount: int64(data["queue_count"].(int)),
Ipv6AccessConfigs: expandIpv6AccessConfigs(data["ipv6_access_config"].([]interface{})),
}
}
Expand Down
7 changes: 7 additions & 0 deletions google/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ func resourceComputeInstance() *schema.Resource {
},
},
},

"queue_count": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Description: `The networking queue count that's specified by users for the network interface. Both Rx and Tx queues will be set to this number. It will be empty if not specified.`,
},
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions google/resource_compute_instance_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ func resourceComputeInstanceTemplate() *schema.Resource {
},
},
},
"queue_count": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Description: `The networking queue count that's specified by users for the network interface. Both Rx and Tx queues will be set to this number. It will be empty if not specified.`,
},
},
},
},
Expand Down
46 changes: 46 additions & 0 deletions google/resource_compute_instance_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,28 @@ func TestAccComputeInstanceTemplate_nictype_update(t *testing.T) {
})
}

func TestAccComputeInstanceTemplate_queueCount(t *testing.T) {
t.Parallel()

var instanceTemplate compute.InstanceTemplate
var instanceTemplateName = fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeInstanceTemplate_queueCount(instanceTemplateName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceTemplateExists(
t, "google_compute_instance_template.foobar", &instanceTemplate),
),
},
},
})
}

func testAccCheckComputeInstanceTemplateDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
config := googleProviderConfig(t)
Expand Down Expand Up @@ -2588,3 +2610,27 @@ resource "google_compute_instance_template" "foobar" {
}
`, image, instance, nictype)
}

func testAccComputeInstanceTemplate_queueCount(instanceTemplateName string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_instance_template" "foobar" {
name = "%s"
machine_type = "e2-medium"
network_interface {
network = "default"
access_config {}
queue_count = 2
}
disk {
source_image = data.google_compute_image.my_image.self_link
auto_delete = true
boot = true
}
}
`, instanceTemplateName)
}
44 changes: 44 additions & 0 deletions google/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,23 @@ func TestAccComputeInstance_subnetworkUpdate(t *testing.T) {
})
}

func TestAccComputeInstance_queueCount(t *testing.T) {
t.Parallel()
instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeInstance_queueCountSet(instanceName),
},
computeInstanceImportStep("us-east1-d", instanceName, []string{"allow_stopping_for_update"}),
},
})
}

func TestComputeInstance_networkIPCustomizedDiff(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -6041,3 +6058,30 @@ func testAccComputeInstance_subnetworkUpdateTwo(suffix, instance string) string
}
`, suffix, suffix, suffix, suffix, instance)
}

func testAccComputeInstance_queueCountSet(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 = "e2-medium"
zone = "us-east1-d"
allow_stopping_for_update = true

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

network_interface {
network = "default"
queue_count = 2
}
}
`, instance)
}
2 changes: 2 additions & 0 deletions website/docs/r/compute_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ is desired, you will need to modify your state file manually using
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig
specified, then this instance will have no external IPv6 Internet access. Structure [documented below](#nested_ipv6_access_config).

* `queue_count` - (Optional) The networking queue count that's specified by users for the network interface. Both Rx and Tx queues will be set to this number. It will be empty if not specified.


<a name="nested_access_config"></a>The `access_config` block supports:

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/compute_instance_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ The `disk_encryption_key` block supports:
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig
specified, then this instance will have no external IPv6 Internet access. Structure [documented below](#nested_ipv6_access_config).

* `queue_count` - (Optional) The networking queue count that's specified by users for the network interface. Both Rx and Tx queues will be set to this number. It will be empty if not specified.

<a name="nested_access_config"></a>The `access_config` block supports:

* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's
Expand Down