Skip to content

Commit d92d721

Browse files
Network queue count support (#5438) (#10571)
* Add queue_number * Add network queue * Remove update test, add to instance template Signed-off-by: Modular Magician <[email protected]>
1 parent 74012e9 commit d92d721

8 files changed

+112
-0
lines changed

.changelog/5438.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added support for `queue_count` to `google_compute_instance.network_interface` and `google_compute_instance_template.network_interface`
3+
```

google/compute_instance_helpers.go

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ func flattenNetworkInterfaces(d *schema.ResourceData, config *Config, networkInt
199199
"nic_type": iface.NicType,
200200
"stack_type": iface.StackType,
201201
"ipv6_access_config": flattenIpv6AccessConfigs(iface.Ipv6AccessConfigs),
202+
"queue_count": iface.QueueCount,
202203
}
203204
// Instance template interfaces never have names, so they're absent
204205
// in the instance template network_interface schema. We want to use the
@@ -279,6 +280,7 @@ func expandNetworkInterfaces(d TerraformResourceData, config *Config) ([]*comput
279280
AliasIpRanges: expandAliasIpRanges(data["alias_ip_range"].([]interface{})),
280281
NicType: data["nic_type"].(string),
281282
StackType: data["stack_type"].(string),
283+
QueueCount: int64(data["queue_count"].(int)),
282284
Ipv6AccessConfigs: expandIpv6AccessConfigs(data["ipv6_access_config"].([]interface{})),
283285
}
284286
}

google/resource_compute_instance.go

+7
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ func resourceComputeInstance() *schema.Resource {
395395
},
396396
},
397397
},
398+
399+
"queue_count": {
400+
Type: schema.TypeInt,
401+
Optional: true,
402+
ForceNew: true,
403+
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.`,
404+
},
398405
},
399406
},
400407
},

google/resource_compute_instance_template.go

+6
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ func resourceComputeInstanceTemplate() *schema.Resource {
426426
},
427427
},
428428
},
429+
"queue_count": {
430+
Type: schema.TypeInt,
431+
Optional: true,
432+
ForceNew: true,
433+
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.`,
434+
},
429435
},
430436
},
431437
},

google/resource_compute_instance_template_test.go

+46
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,28 @@ func TestAccComputeInstanceTemplate_nictype_update(t *testing.T) {
10311031
})
10321032
}
10331033

1034+
func TestAccComputeInstanceTemplate_queueCount(t *testing.T) {
1035+
t.Parallel()
1036+
1037+
var instanceTemplate compute.InstanceTemplate
1038+
var instanceTemplateName = fmt.Sprintf("tf-test-%s", randString(t, 10))
1039+
1040+
vcrTest(t, resource.TestCase{
1041+
PreCheck: func() { testAccPreCheck(t) },
1042+
Providers: testAccProviders,
1043+
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
1044+
Steps: []resource.TestStep{
1045+
{
1046+
Config: testAccComputeInstanceTemplate_queueCount(instanceTemplateName),
1047+
Check: resource.ComposeTestCheckFunc(
1048+
testAccCheckComputeInstanceTemplateExists(
1049+
t, "google_compute_instance_template.foobar", &instanceTemplate),
1050+
),
1051+
},
1052+
},
1053+
})
1054+
}
1055+
10341056
func testAccCheckComputeInstanceTemplateDestroyProducer(t *testing.T) func(s *terraform.State) error {
10351057
return func(s *terraform.State) error {
10361058
config := googleProviderConfig(t)
@@ -2588,3 +2610,27 @@ resource "google_compute_instance_template" "foobar" {
25882610
}
25892611
`, image, instance, nictype)
25902612
}
2613+
2614+
func testAccComputeInstanceTemplate_queueCount(instanceTemplateName string) string {
2615+
return fmt.Sprintf(`
2616+
data "google_compute_image" "my_image" {
2617+
family = "debian-9"
2618+
project = "debian-cloud"
2619+
}
2620+
2621+
resource "google_compute_instance_template" "foobar" {
2622+
name = "%s"
2623+
machine_type = "e2-medium"
2624+
network_interface {
2625+
network = "default"
2626+
access_config {}
2627+
queue_count = 2
2628+
}
2629+
disk {
2630+
source_image = data.google_compute_image.my_image.self_link
2631+
auto_delete = true
2632+
boot = true
2633+
}
2634+
}
2635+
`, instanceTemplateName)
2636+
}

google/resource_compute_instance_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,23 @@ func TestAccComputeInstance_subnetworkUpdate(t *testing.T) {
21692169
})
21702170
}
21712171

2172+
func TestAccComputeInstance_queueCount(t *testing.T) {
2173+
t.Parallel()
2174+
instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10))
2175+
2176+
vcrTest(t, resource.TestCase{
2177+
PreCheck: func() { testAccPreCheck(t) },
2178+
Providers: testAccProviders,
2179+
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
2180+
Steps: []resource.TestStep{
2181+
{
2182+
Config: testAccComputeInstance_queueCountSet(instanceName),
2183+
},
2184+
computeInstanceImportStep("us-east1-d", instanceName, []string{"allow_stopping_for_update"}),
2185+
},
2186+
})
2187+
}
2188+
21722189
func TestComputeInstance_networkIPCustomizedDiff(t *testing.T) {
21732190
t.Parallel()
21742191

@@ -6041,3 +6058,30 @@ func testAccComputeInstance_subnetworkUpdateTwo(suffix, instance string) string
60416058
}
60426059
`, suffix, suffix, suffix, suffix, instance)
60436060
}
6061+
6062+
func testAccComputeInstance_queueCountSet(instance string) string {
6063+
return fmt.Sprintf(`
6064+
data "google_compute_image" "my_image" {
6065+
family = "debian-9"
6066+
project = "debian-cloud"
6067+
}
6068+
6069+
resource "google_compute_instance" "foobar" {
6070+
name = "%s"
6071+
machine_type = "e2-medium"
6072+
zone = "us-east1-d"
6073+
allow_stopping_for_update = true
6074+
6075+
boot_disk {
6076+
initialize_params {
6077+
image = data.google_compute_image.my_image.id
6078+
}
6079+
}
6080+
6081+
network_interface {
6082+
network = "default"
6083+
queue_count = 2
6084+
}
6085+
}
6086+
`, instance)
6087+
}

website/docs/r/compute_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ is desired, you will need to modify your state file manually using
304304
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig
305305
specified, then this instance will have no external IPv6 Internet access. Structure [documented below](#nested_ipv6_access_config).
306306

307+
* `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.
308+
307309

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

website/docs/r/compute_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ The `disk_encryption_key` block supports:
383383
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig
384384
specified, then this instance will have no external IPv6 Internet access. Structure [documented below](#nested_ipv6_access_config).
385385

386+
* `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.
387+
386388
<a name="nested_access_config"></a>The `access_config` block supports:
387389

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

0 commit comments

Comments
 (0)