Skip to content

fix(vm): prevent over-creation of vmmac on additional interface updates#2184

Open
LopatinDmitr wants to merge 1 commit intomainfrom
fix/vm/adding-additional-network-interfaces
Open

fix(vm): prevent over-creation of vmmac on additional interface updates#2184
LopatinDmitr wants to merge 1 commit intomainfrom
fix/vm/adding-additional-network-interfaces

Conversation

@LopatinDmitr
Copy link
Copy Markdown
Contributor

@LopatinDmitr LopatinDmitr commented Apr 2, 2026

Description

Fix two issues in VM additional network handling:

  1. Prevent over-creation of VirtualMachineMACAddress resources when adding additional interfaces.
  2. Fix network interface ID assignment when some IDs are already reserved later in the spec list.

The MAC handler now creates only the missing amount of VMMAC resources.

EnsureNetworkInterfaceIDs now pre-collects all already assigned positive IDs before allocating missing ones, so generated IDs do not collide with IDs that appear later in the network list.

Regression tests were added for both cases.

Why do we need it, and what problem does it solve?

Two bugs were observed during additional interface updates:

  • Adding one additional interface could create multiple (2-3) VMMAC/VMMACL resources instead of exactly one.
  • Missing interface IDs could be assigned incorrectly when some explicit IDs existed later in spec.networks, leading to unstable or conflicting IDs.

This patch makes both resource creation and ID allocation deterministic.

What is the expected result?

  1. Create a VM with one additional network interface.
  2. Ensure one VMMAC is present.
  3. Add one more additional interface.
  4. Verify exactly one more VMMAC is created (total equals number of non-main interfaces).
  5. Verify missing network IDs are assigned to minimal free values without collisions with pre-set IDs anywhere in the list.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm
type: fix
summary: Prevent over-creation of VirtualMachineMACAddress resources and fix network interface ID allocation for additional VM networks.
impact_level: low

Signed-off-by: Dmitry Lopatin <dmitry.lopatin@flant.com>
@LopatinDmitr LopatinDmitr changed the title fix(network): prevent over-creation of vmmac on additional interface updates fix(vm): prevent over-creation of vmmac on additional interface updates Apr 2, 2026
@LopatinDmitr LopatinDmitr added this to the v1.8.0 milestone Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants