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

pool: Randomize mac #447

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RamLavi
Copy link
Member

@RamLavi RamLavi commented Dec 30, 2024

What this PR does / why we need it:
Currently, the MAC allocation strategy relied on sequential assignment.
The system kept track of the last allocated MAC and assigned the next sequential MAC unless it was already in use.
This approach can cause issues in specific use cases where multi-clusters are merged into one, increasing the likelihood of MAC conflict.
Changing the algorithm to be random to ensure more robust MAC allocation for dynamic and distributed environments.

Special notes for your reviewer:

Release note:

NONE

@kubevirt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from ramlavi. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

The networks and network-status annotations consts are set on multus
repo, and controlled by it. Using their consts to keep consistency.

Signed-off-by: Ram Lavi <[email protected]>
There is no good reason to use these functions as closure functions.
Moving them to be regular functions, thus reducing code complexity.

Signed-off-by: Ram Lavi <[email protected]>
Currently not all unit tests check macpool size after doing changes in
the macpool map (allocate, update or delete MACs entries)
Moving the check inside checkMacPoolMapEntries so that all tests check
this, removing the now redundant checks.
Also refactoring use of "errors.New(fmt.Sprintf(...))" into
"fmt.Errorf(...)"

Signed-off-by: Ram Lavi <[email protected]>
Previously, the MAC allocation strategy relied on sequential assignment.
The system kept track of the last allocated MAC and assigned the next
sequential MAC unless it was already in use.

This approach can cause issues in specific use cases where
multi-clusters are merged into one, increasing the likelihood of MAC
conflict.
Changing the algorithm to be random to ensure more robust MAC allocation
for dynamic and distributed environments.
Fix unit tests appropriately, and also add unit test for full MAC Pool.

Signed-off-by: Ram Lavi <[email protected]>
Since now MAC allocation is done randomly, it is better to increase the
MAC pool range to be large, to greatly reduce cases where the randomly
allocated MAC is the one accidentally expected by the tests.
Also change managedNamespaceMAC, unmanagedNamespaceMAC to be outside of
this range to reduce rare cases where the MAC allocator will assign that
MAC to the interfaces, creating a forbidden duplication.

Signed-off-by: Ram Lavi <[email protected]>
@RamLavi
Copy link
Member Author

RamLavi commented Dec 31, 2024

/hold
depends on #448

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

Successfully merging this pull request may close these issues.

2 participants