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

net: exclude OVS internal interfaces in get_interfaces #829

Merged
merged 1 commit into from
Mar 8, 2021

Conversation

OddBloke
Copy link
Collaborator

@OddBloke OddBloke commented Mar 3, 2021

Proposed Commit Message

net: exclude OVS internal interfaces in get_interfaces

`get_interfaces` is used to in two ways, broadly: firstly, to determine
the available interfaces when converting cloud network configuration
formats to cloud-init's network configuration formats; and, secondly, to
ensure that any interfaces which are specified in network configuration
are (a) available, and (b) named correctly.  The first of these is
unaffected by this commit, as no clouds support Open vSwitch
configuration in their network configuration formats.

For the second, we check that MAC addresses of physical devices are
unique.  In some OVS configurations, there are OVS-created devices which
have duplicate MAC addresses, either with each other or with physical
devices.  As these interfaces are created by OVS, we can be confident
that (a) they will be available when appropriate, and (b) that OVS will
name them correctly.  As such, this commit excludes any OVS-internal
interfaces from the set of interfaces returned by `get_interfaces`.

LP: #1912844

Test Steps

Use included integration test.

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

@OddBloke OddBloke added the wip Work in progress, do not land label Mar 3, 2021
user_data=SETUP_USER_DATA,
) as instance:
instance.instance.clean()
session_cloud.snapshot_id = instance.snapshot()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I wonder if this is going to mean that this OVS-enabled image is used for all future launches: I'll check now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is; working on this now.

Copy link
Collaborator

@raharper raharper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks well done. Some in-line questions.

cloudinit/net/__init__.py Outdated Show resolved Hide resolved
cloudinit/net/__init__.py Show resolved Hide resolved
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think main implementation and unit tests look good. I'll revisit when the WIP tag is removed since you're still working on the integration test.

Not necessary for this PR but...
Given the fairly random places I'm seeing

@mock.patch(
    "cloudinit.net.is_openvswitch_internal_interface",
    mock.Mock(return_value=False),
)

I'm wondering if it might make sense to create a top-level autorun fixture that provides default mocks for things that we obviously don't want running in unit tests. In this case we would default is_openvswitch_internal_interface to False, and then actual openvswitch tests could change it to True when needed.

cloudinit/net/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@fnordahl fnordahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm speaking only for the Open vSwitch specific bits in this patch set, and as we have discussed on the LP this is a good approach and LGTM.

`get_interfaces` is used to in two ways, broadly: firstly, to determine
the available interfaces when converting cloud network configuration
formats to cloud-init's network configuration formats; and, secondly, to
ensure that any interfaces which are specified in network configuration
are (a) available, and (b) named correctly.  The first of these is
unaffected by this commit, as no clouds support Open vSwitch
configuration in their network configuration formats.

For the second, we check that MAC addresses of physical devices are
unique.  In some OVS configurations, there are OVS-created devices which
have duplicate MAC addresses, either with each other or with physical
devices.  As these interfaces are created by OVS, we can be confident
that (a) they will be available when appropriate, and (b) that OVS will
name them correctly.  As such, this commit excludes any OVS-internal
interfaces from the set of interfaces returned by `get_interfaces`.

LP: #1912844
@OddBloke OddBloke removed the wip Work in progress, do not land label Mar 5, 2021
@OddBloke OddBloke changed the title WIP: net: exclude OVS internal interfaces in get_interfaces net: exclude OVS internal interfaces in get_interfaces Mar 5, 2021
@OddBloke OddBloke merged commit 121bc04 into canonical:master Mar 8, 2021
@OddBloke OddBloke deleted the ovs branch March 8, 2021 17:51
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.

4 participants