feat(opennebula): support global SEARCH_DOMAIN for all interfaces#6813
feat(opennebula): support global SEARCH_DOMAIN for all interfaces#6813mcanevet wants to merge 1 commit intocanonical:mainfrom
Conversation
c7ac073 to
4594165
Compare
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.) |
4594165 to
2deb1ab
Compare
|
@blackboxsw rebased |
netbox-network-config sets a global SEARCH_DOMAIN context variable (never per-interface ETHx_SEARCH_DOMAIN). The existing get_nameservers() already handled the global DNS key but silently ignored SEARCH_DOMAIN, leaving VMs with no DNS search domain configured. Extend get_nameservers() to append entries from the global SEARCH_DOMAIN key, matching the existing pattern for global DNS. Per-interface ETHx_SEARCH_DOMAIN entries take precedence and duplicates are suppressed.
2deb1ab to
41e826c
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenNebula datasource’s network-config generation to honor a global SEARCH_DOMAIN context key (in addition to the existing per-interface ETHx_SEARCH_DOMAIN), ensuring DNS search domains are configured even when only the global key is provided.
Changes:
- Extend
OpenNebulaNetwork.get_nameservers()to merge globalSEARCH_DOMAINinto per-interface search domains while suppressing duplicates. - Add unit tests covering global-only, merged per-interface + global, and multi-NIC propagation behavior.
- Document
SEARCH_DOMAINas a supported OpenNebula context variable and describe merge precedence.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cloudinit/sources/DataSourceOpenNebula.py |
Merge global SEARCH_DOMAIN into the generated netplan nameservers.search list with de-duplication vs per-interface values. |
tests/unittests/sources/test_opennebula.py |
Add targeted tests for global SEARCH_DOMAIN behavior in get_nameservers() and gen_conf(). |
doc/rtd/reference/datasources/opennebula.rst |
Document SEARCH_DOMAIN and describe how global/per-interface DNS-related keys interact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fallbacks applied to every interface. Per-interface ``ETH<x>_DNS`` and | ||
| ``ETH<x>_SEARCH_DOMAIN`` take precedence; duplicate entries are suppressed. |
| if dns: | ||
| nameservers["addresses"] = dns | ||
| search_domain = self.get_field(dev, "search_domain", "").split() | ||
| for domain in self.context.get("SEARCH_DOMAIN", "").split(): | ||
| if domain not in search_domain: |
| } | ||
| net = ds.OpenNebulaNetwork(context, mock.Mock()) | ||
| val = net.get_nameservers("eth0") | ||
| assert val["search"].count("shared.example.com") == 1 |
Proposed Commit Message
Additional Context
Part of a series bringing cloud-init's OpenNebula datasource to feature
parity with the context-linux package from one-apps.
The global
DNSkey was already handled byget_nameservers()(line 179of
DataSourceOpenNebula.py).SEARCH_DOMAINis its natural counterpartand follows the exact same pattern.
Test Steps
In an OpenNebula VM context, set:
SEARCH_DOMAIN="example.com example.org"After boot, verify
/etc/resolv.conf(or systemd-resolved config) containssearch example.com example.org.Also verify that setting both
ETH0_SEARCH_DOMAIN="iface.example.com"andSEARCH_DOMAIN="global.example.com"results in both domains present withoutduplication.
Merge type