Skip to content

Commit 84a69bb

Browse files
a-r-ncopybara-github
authored andcommitted
networkutils: Support flag-defined provisioning model, use correct access configs for RDMA NICs
The default access config includes ONE_TO_ONE_NAT which is invalid for RDMA NICs. PiperOrigin-RevId: 934440654
1 parent 24ea069 commit 84a69bb

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

utils/networkutils/networkutils.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ var (
4949
// NICTypesFlag is the flag to specify the NIC types to use in the test.
5050
NICTypesFlag = flag.String("networkutils_nic_types", "GVNIC:1", "NIC types. Comma separated list of <NIC_TYPE>:<COUNT>. e.g. \"GVNIC:2\" or \"GVNIC:2,MRDMA:8\". If unspecified, defaults to a single GVNIC.")
5151

52+
// ProvisioningModelFlag is the flag to specify the provisioning model to use when creating
53+
// instances.
54+
ProvisioningModelFlag = flag.String("networkutils_provisioning_model", "STANDARD", "Provisioning model to use when creating instances. One of [STANDARD, SPOT]. See https://docs.cloud.google.com/compute/docs/instances/provisioning-models.")
55+
5256
// EthtoolDriverRe is a regex to extract the driver name from the `ethtool -i` output.
5357
EthtoolDriverRe = regexp.MustCompile(`(?m)^driver:\s*(.*)$`)
5458

@@ -268,6 +272,16 @@ func daisySubnet(index int, zone string) (*daisy.Subnetwork, error) {
268272
}, nil
269273
}
270274

275+
func accessConfigsForNIC(nicType string) []*compute.AccessConfig {
276+
if nicType == NICTypeIRDMA || nicType == NICTypeMRDMA {
277+
return []*compute.AccessConfig{}
278+
}
279+
return []*compute.AccessConfig{&compute.AccessConfig{
280+
Name: "External NAT",
281+
Type: "ONE_TO_ONE_NAT",
282+
}}
283+
}
284+
271285
// CreateMachineWithNetworksOptions contains the options for creating a machine with multiple
272286
// network interfaces.
273287
type CreateMachineWithNetworksOptions struct {
@@ -304,12 +318,18 @@ func CreateMachineWithNetworks(t *imagetest.TestWorkflow, o *CreateMachineWithNe
304318
}
305319

306320
m.NetworkInterfaces = append(m.NetworkInterfaces, &compute.NetworkInterface{
307-
NicType: nicType,
308-
Network: daisyNetwork.Name,
309-
Subnetwork: daisySubnet.Name,
321+
NicType: nicType,
322+
Network: daisyNetwork.Name,
323+
Subnetwork: daisySubnet.Name,
324+
AccessConfigs: accessConfigsForNIC(nicType),
310325
})
311326
}
312327

328+
m.Scheduling = &compute.Scheduling{
329+
OnHostMaintenance: imagetest.MachineMaintenancePolicy(o.MachineType),
330+
ProvisioningModel: *ProvisioningModelFlag,
331+
}
332+
313333
return m, nil
314334
}
315335

0 commit comments

Comments
 (0)