-
Notifications
You must be signed in to change notification settings - Fork 908
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: introduce find_candidate_nics() #1313
Conversation
continue | ||
driver = device_driver(interface) | ||
if driver in blacklist_drivers: | ||
LOG.debug( |
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.
I don't know if these debug logs are excessive, but I figured we may want to have some indication of why we are ignoring candidate NICs.
5cbc43e
to
90b7ce6
Compare
find_fallback_nic_on_linux(), etc. provides valuable filtering of network interfaces in an effort to determine the best candidate for the fallback interface. Expose this logic with a new set of methods for finding the candidate network interfaces. These methods can be used by data sources which cannot rely on the fallback interface being the correct choice. Note that the MAC address filtering is now part of find_candidate_nics_on_linux(). This should be consistent behavior as find_fallback_nic_on_linux() never selected an interface without a MAC. find_fallback_nic_on_linux() continues to prefer eth0, but we make no such distinction in the candidate search. Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
90b7ce6
to
dcf224e
Compare
@eb3095 This may be of interest to you? |
Indeed, was hoping it was ready for the last PR, but left a note in a comment about switching out for it when it was available. This solves a few issues for us as well. |
cloudinit/net/__init__.py
Outdated
@@ -389,8 +389,23 @@ def is_disabled_cfg(cfg): | |||
return cfg.get("config") == "disabled" | |||
|
|||
|
|||
def find_fallback_nic(blacklist_drivers=None): | |||
"""Return the name of the 'fallback' network device.""" | |||
def find_candidate_nics(blacklist_drivers: Optional[List] = None) -> List[str]: |
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.
should these be Optional[List[str]]
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.
Good point fixed everywhere!
Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
cae07aa
to
1d84f8e
Compare
Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
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.
LGTM! This is really convenient refactor and also simplifying of some of the logic. Thanks!
Wrt to the debug logs, I think it is fine. Better to have a trail than nothing at all.
find_fallback_nic_on_linux(), etc. provides valuable filtering of
network interfaces in an effort to determine the best candidate
for the fallback interface.
Expose this logic with a new set of methods for finding the candidate
network interfaces. These methods can be used by data sources which
cannot rely on the fallback interface being the correct choice.
Note that the MAC address filtering is now part of
find_candidate_nics_on_linux(). This should be consistent behavior
as find_fallback_nic_on_linux() never selected an interface without
a MAC. find_fallback_nic_on_linux() continues to prefer eth0,
but we make no such distinction in the candidate search.
Signed-off-by: Chris Patterson cpatterson@microsoft.com