Skip to content

fix: consolidate custom network interface when nic type is preconfigured - #588

Open
adi-IL wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
adi-IL:fix/custom-network-gvnic-interface-consolidation
Open

fix: consolidate custom network interface when nic type is preconfigured#588
adi-IL wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
adi-IL:fix/custom-network-gvnic-interface-consolidation

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 23, 2026

Copy link
Copy Markdown

Fixes #500

What was wrong
When TestVM.UseGVNIC() was called prior to TestVM.AddCustomNetwork(), UseGVNIC() initialized NetworkInterfaces with a single entry containing NicType: "GVNIC" and an empty Network field. Subsequent calls to AddCustomNetworkWithStackType() appended a second network interface rather than configuring the primary NIC. This caused test VMs to spin up with two network interfaces (where NIC 0 defaulted to the default VPC network and NIC 1 had the custom network), leading to failures in environments without a default VPC.

What changed

  • Updated AddCustomNetworkWithStackType in fixtures.go for both instance and instancebeta to inspect existing network interfaces. If a single preconfigured NIC without an assigned network exists (such as from a prior UseGVNIC() call), it updates the primary interface with the custom network and preserves the preconfigured NicType.
  • Added unit test TestAddCustomNetworkGVNICConsolidation in fixtures_test.go covering UseGVNIC() followed by AddCustomNetwork(), AddCustomNetwork() followed by UseGVNIC(), and beta instance consolidation.

Verification

  • go test -v -run TestAddCustomNetworkGVNICConsolidation . -> PASS
  • go test . ./cleanerupper/... ./utils/... -> all unit tests PASS
  • gofmt -d fixtures.go fixtures_test.go -> clean formatting
@google-oss-prow

Copy link
Copy Markdown

Hi @adi-IL. Thanks for your PR.

I'm waiting for a GoogleCloudPlatform member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant