Skip to content

feat(opennebula): support global SEARCH_DOMAIN for all interfaces#6813

Open
mcanevet wants to merge 1 commit intocanonical:mainfrom
mcanevet:feat/opennebula-search-domain
Open

feat(opennebula): support global SEARCH_DOMAIN for all interfaces#6813
mcanevet wants to merge 1 commit intocanonical:mainfrom
mcanevet:feat/opennebula-search-domain

Conversation

@mcanevet
Copy link
Copy Markdown
Contributor

Proposed Commit Message

feat(opennebula): support global SEARCH_DOMAIN for all interfaces

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.

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 DNS key was already handled by get_nameservers() (line 179
of DataSourceOpenNebula.py). SEARCH_DOMAIN is its natural counterpart
and 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) contains
search example.com example.org.

Also verify that setting both ETH0_SEARCH_DOMAIN="iface.example.com" and
SEARCH_DOMAIN="global.example.com" results in both domains present without
duplication.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@github-actions github-actions Bot added the documentation This Pull Request changes documentation label Mar 30, 2026
@mcanevet mcanevet force-pushed the feat/opennebula-search-domain branch 3 times, most recently from c7ac073 to 4594165 Compare April 1, 2026 08:31
@github-actions
Copy link
Copy Markdown

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.)

@github-actions github-actions Bot added the stale-pr Pull request is stale; will be auto-closed soon label Apr 16, 2026
@blackboxsw blackboxsw removed the stale-pr Pull request is stale; will be auto-closed soon label Apr 21, 2026
@mcanevet mcanevet force-pushed the feat/opennebula-search-domain branch from 4594165 to 2deb1ab Compare April 22, 2026 06:33
@mcanevet
Copy link
Copy Markdown
Contributor Author

@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.
@mcanevet mcanevet force-pushed the feat/opennebula-search-domain branch from 2deb1ab to 41e826c Compare May 5, 2026 14:32
Copilot AI review requested due to automatic review settings May 5, 2026 14:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 global SEARCH_DOMAIN into per-interface search domains while suppressing duplicates.
  • Add unit tests covering global-only, merged per-interface + global, and multi-NIC propagation behavior.
  • Document SEARCH_DOMAIN as 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.

Comment on lines +79 to +80
fallbacks applied to every interface. Per-interface ``ETH<x>_DNS`` and
``ETH<x>_SEARCH_DOMAIN`` take precedence; duplicate entries are suppressed.
Comment on lines 190 to +194
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation This Pull Request changes documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants