-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement binding strategy in creating and binding lport #111
Open
huikang
wants to merge
2
commits into
ovn-org:master
Choose a base branch
from
huikang:add-binding-strategy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
====================== | ||
Binding Strategy Guide | ||
====================== | ||
|
||
Overview | ||
======== | ||
|
||
In OVN, a logical port can be bind to a local OVS port on any | ||
chassis/hypervisor, depending on the VM scheduler (e.g., ``nova-scheduler``). | ||
The binding strategy potentially impacts the network performance. That is | ||
binding all logical ports from a logical network on a single hypervisor performs | ||
differently than distributing the ports on multiple hypervisors. | ||
|
||
The container-based ovn-scale-test deployment allows to configure the binding | ||
strategy in creating and binding port rally task. | ||
|
||
|
||
Binding Configuration | ||
===================== | ||
|
||
Use ``networks_per_sandbox`` to control how logical networks and the logical | ||
ports are bind to chassis. | ||
|
||
For example, given ``ovn_number_chassis: 10`` (4 emulated chassis) and | ||
``ovn_number_chassis: 10`` (10 logical networks), the binding varies depending | ||
on the value of ``networks_per_sandbox``. | ||
|
||
- ``networks_per_sandbox: "10"``: this is the default case. All networks will | ||
be evenly distributed to all chassis. | ||
|
||
- ``networks_per_sandbox: "2"``: each chassis has ports belong to two logical | ||
networks. In this case, the 10 logical networks are divided into 5 groups, say | ||
[n0, n1], [n2, n3], [n4, n5], [n6, n7], [n8, n9]. Then ports in [n0, n1] are | ||
bind to chassis 0 and 1, [n2, n3] to chassis 2 and 3, and so forth. As a | ||
result, each chassis has two logical network as configured. | ||
|
||
- ``networks_per_sandbox: "1"``: each chassis has ports belong to only one | ||
logical network. In this case, the 10 logical network will have a one-to-one | ||
mapping to the 10 chassis. Note that this is the extreme case as opposite to | ||
``networks_per_sandbox: "10"``. | ||
|
||
|
||
Constraint | ||
~~~~~~~~~ | ||
|
||
TBD | ||
|
||
Implementation Detail | ||
===================== | ||
|
||
TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,105 @@ | |
from rally.common import logging | ||
from rally_ovs.plugins.ovs.scenarios import ovn | ||
|
||
from rally import exceptions | ||
from rally.task import scenario | ||
from rally.task import validation | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
class LogicalNetwork(): | ||
def __init__(self): | ||
self.sandboxes = [] | ||
self.ports_per_network = 0 | ||
|
||
def set_lswitch(self, lswitch): | ||
self.lswitch = lswitch | ||
|
||
def add_sandbox(self, sandbox): | ||
self.sandboxes.append(sandbox) | ||
|
||
def get_lswitch(self): | ||
return self.lswitch | ||
|
||
def get_sandboxes(self): | ||
return self.sandboxes | ||
|
||
def get_ports_per_network(self): | ||
return self.ports_per_network | ||
|
||
|
||
def initialize_logical_networks(lswitches): | ||
LOG.info("Initialize logical lswitches with %s" % lswitches) | ||
logical_networks = [] | ||
|
||
for lswitch in lswitches: | ||
logical_network = LogicalNetwork() | ||
logical_network.set_lswitch(lswitch) | ||
LOG.info("Logical network: %s" % logical_network.get_lswitch()) | ||
logical_networks.append(logical_network) | ||
|
||
return logical_networks | ||
|
||
|
||
def allocate_networks_on_sandboxes(logical_networks, sandboxes, networks_per_sandbox=0): | ||
if networks_per_sandbox == 0: | ||
for logical_network in logical_networks: | ||
for sandbox in sandboxes: | ||
logical_network.add_sandbox(sandbox) | ||
else: | ||
# Sanity check | ||
num_networks = len(logical_networks) | ||
|
||
if (num_networks % networks_per_sandbox) != 0 : | ||
message = ("Number of network %s is not divisible by network per sandbox %s") | ||
raise exceptions.InvalidConfigException( | ||
message % (str(num_networks), str(networks_per_sandbox))) | ||
|
||
LOG.info("Number of networks: %s" % str(num_networks)) | ||
num_network_groups = num_networks / networks_per_sandbox | ||
LOG.info("Number of network group: %s" % str(num_network_groups)) | ||
|
||
if len(sandboxes) < num_network_groups : | ||
message = ("Number of sandbox %d is less than number of network groups %d") | ||
raise exceptions.InvalidConfigException( | ||
message % (len(sandboxes), num_network_groups)) | ||
elif (len(sandboxes) % num_network_groups) != 0 : | ||
message = ("Number of sandbox %d is not divisible by network groups %d") | ||
raise exceptions.InvalidConfigException( | ||
message % (len(sandboxes), num_network_groups)) | ||
|
||
|
||
group_spread_sandboxes = len(sandboxes) / num_network_groups | ||
LOG.info("Number of group spread sandboxes: %s" % str(group_spread_sandboxes)) | ||
|
||
network_groups = [] | ||
networks_per_group = num_networks / num_network_groups | ||
base = 0 | ||
for i in range(0, num_network_groups): | ||
LOG.info("Group %d" % i) | ||
network_group = [] | ||
|
||
for j in range(base, base + networks_per_group): | ||
network_group.append(logical_networks[j]) | ||
LOG.info("\t%d, add logical network: %s" % (j, logical_networks[j].get_lswitch())) | ||
|
||
LOG.info("network group idx0: %s" % network_group[0].get_lswitch()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'idx0' is a typo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a debug message. I will remove it. Thanks. |
||
|
||
network_groups.append(network_group) | ||
base += networks_per_group | ||
|
||
LOG.info("Allocating sandboxes...") | ||
sandbox_idx = 0 | ||
base = 0 | ||
for group in network_groups: | ||
for network in group: | ||
LOG.info("network switch name: %s" % network.get_lswitch()) | ||
for sandbox_idx in range(base, base + group_spread_sandboxes): | ||
network.add_sandbox(sandboxes[sandbox_idx]) | ||
LOG.info("\tAdd sandbox %s" % sandboxes[sandbox_idx]) | ||
base += group_spread_sandboxes | ||
|
||
return logical_networks | ||
|
||
class OvnNetwork(ovn.OvnScenario): | ||
"""scenarios for OVN network.""" | ||
|
@@ -35,16 +128,23 @@ def create_networks(self, network_create_args): | |
@scenario.configure(context={}) | ||
def create_and_bind_ports(self, | ||
network_create_args=None, | ||
networks_per_sandbox=None, | ||
port_create_args=None, | ||
ports_per_network=None, | ||
port_bind_args=None): | ||
|
||
sandboxes = self.context["sandboxes"] | ||
|
||
lswitches = self._create_networks(network_create_args) | ||
for lswitch in lswitches: | ||
lports = self._create_lports(lswitch, port_create_args, ports_per_network) | ||
self._bind_ports(lports, sandboxes, port_bind_args) | ||
logical_networks = [] | ||
logical_networks = initialize_logical_networks(lswitches) | ||
if networks_per_sandbox == None: | ||
networks_per_sandbox = 0 | ||
logical_networks = allocate_networks_on_sandboxes(logical_networks, sandboxes, networks_per_sandbox) | ||
|
||
for logical_network in logical_networks: | ||
lports = self._create_lports(logical_network.get_lswitch(), port_create_args, ports_per_network) | ||
self._bind_ports(lports, logical_network.get_sandboxes(), port_bind_args) | ||
|
||
|
||
def bind_ports(self): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to add 'self.lswitch = None' in init(), otherwise get_lswitch() before set_lswitch() may raise a exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got you. Thanks.