Added: support for multiple network interfaces in openstack datasource#6877
Added: support for multiple network interfaces in openstack datasource#6877mklejn-ovh wants to merge 1 commit into
Conversation
blackboxsw
left a comment
There was a problem hiding this comment.
Basic approach looks good here thanks @mklejn-ovh. I realize that enumerating and walking through multiple interfaces with DHCP requests may lead to delays on BIG systems with multiple NICs if the primary NIC doesn't have DHCP on the attached network.
I think this approach for NIC discovery is ok as you mentioned that NIC attach ordering to VMs is what matters here. Since cloud-init generally prefers that a platform have its primary NIC connected to the platform with access to the instance metadata service (and DHCP), any configuration which diverges from that expectation will either hit 'no IMDS connectivity' issues as you are trying to fix here, or slight delays trying to process non-primary NICs first before finding the right one.
Let's also add a small doc update about multi-NIC discovery in doc/rtd/reference/datasources/openstack.rst.
| NoDHCPLeaseError, | ||
| sources.InvalidMetaDataException, |
There was a problem hiding this comment.
This approach aligns with what we have currently in GCE datasource with two things missing:
I think we want to distinguish NoDHCPLeaseError condition by logging "Unable to obtain a DHCP lease for "
| NoDHCPLeaseError, | ||
| sources.InvalidMetaDataException, | ||
| ) as e: | ||
| util.logexc(LOG, str(e)) |
There was a problem hiding this comment.
Generally there is not a lot of value in logging the related traceback via util.logexc if we can valid it. Our common logging pattern gives is the module cloud-init is logging from, so the additional traceback info is nothing more than a lot of noise in our already busy logs. Since you are touching this area. Maybe we make an effort to LOG.debug("OpenStack metadata error: %s") vs "Unable to obtain DHCP lease on %s" etc.
| util.logexc(LOG, str(e)) | ||
| if not results: | ||
| LOG.warning( | ||
| "All interfaces failed to get dhcp lease" |
There was a problem hiding this comment.
| "All interfaces failed to get dhcp lease" | |
| "All interfaces failed to get DHCP lease. " |
| if not results: | ||
| LOG.warning( | ||
| "All interfaces failed to get dhcp lease" | ||
| "Metadata service will NOT be called" |
There was a problem hiding this comment.
| "Metadata service will NOT be called" | |
| " OpenStack metadata service will NOT be called" |
| def get_interface_list(self): | ||
| ifaces = [] | ||
| for iface in net.find_candidate_nics(): | ||
| if "dummy" in iface: |
There was a problem hiding this comment.
I wonder if we want to promote this logic into net.find_candidate_nics directly. I see Vultr also attempts to ignore this iface name and I think it's generally irrelevant as a candidate.
| return True | ||
|
|
||
| def _crawl_metadata(self): | ||
| def _crawl_metadata(self, iface=None): |
There was a problem hiding this comment.
Since you are touching functions, please add type hints to function params and expected return values to aid in mypy verification.
| return mstr | ||
|
|
||
| def wait_for_metadata_service(self): | ||
| def wait_for_metadata_service(self, iface): |
There was a problem hiding this comment.
Please add typing hints for function returns and params to aid our mypy CI validation.
Proposed Commit Message
Additional Context
Right here: GH-6786
Test Steps
Right here: GH-6786
Merge type