Skip to content

feat: Enhance DHCP release process with dhclient check and logging - #48

Merged
adrianlasota merged 1 commit into
mainfrom
dhcp
May 18, 2026
Merged

adrianlasota merged 1 commit into
mainfrom
dhcp

Conversation

@adrianlasota

@adrianlasota adrianlasota commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

This pull request improves the robustness of the release_ip method in the Linux IP feature implementation by handling cases where dhclient is not present, and updates the corresponding unit tests to cover these scenarios.

Enhancements to release_ip method:

  • Added a check to see if dhclient is available before attempting to release the DHCP lease, and logs a debug message if it is not found.
  • Ensured that the ip addr flush command is always run in the correct network namespace by wrapping it with add_namespace_call_command.

Unit test improvements:

  • Added a test to verify correct behavior when dhclient is not found, ensuring the method skips the DHCP release step and still flushes the IP address.
  • Added a test to verify that an exception is raised if releasing the IP via dhclient fails with an unexpected error.

Copilot AI review requested due to automatic review settings May 5, 2026 09:21
@mfd-intel-bot

Copy link
Copy Markdown
Contributor

We don't publish DEVs .whl.
To build .whl, run 'pip install git+https://github.com/intel/mfd-network-adapter@dhcp'

Copilot AI left a comment

Copy link
Copy Markdown

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 enhances the Linux DHCP release workflow by adding a dhclient presence check and emitting a debug log when the DHCP release step is skipped, along with unit tests for the new branches.

Changes:

  • Add a pre-check for dhclient availability before attempting dhclient -r in LinuxIP.release_ip().
  • Log a debug message when dhclient is not found and the DHCP release step is skipped.
  • Add unit tests covering the “dhclient not found” path and error propagation from dhclient -r.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
mfd_network_adapter/network_interface/feature/ip/linux.py Adds dhclient existence check and skip-logging to the Linux IP release flow.
tests/unit/test_mfd_network_adapter/test_network_interface/test_feature/test_ip/test_ip_linux.py Adds unit tests for the new release_ip() branches (dhclient missing / dhclient error).
Comments suppressed due to low confidence (1)

mfd_network_adapter/network_interface/feature/ip/linux.py:206

  • ip -{ip_version} addr flush dev ... is executed without add_namespace_call_command(...). If the interface is in a network namespace, the flush will run in the default namespace and likely fail / flush the wrong context. Please apply the same namespace wrapping used elsewhere in this module (e.g., del_all_ips() uses add_namespace_call_command).
        cmd = f"ip -{ip_version.value} addr flush dev {self._interface().name}"
        self._connection.execute_command(cmd)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Lasota, Adrian <adrian.lasota@intel.com>
@adrianlasota
adrianlasota merged commit 62129d2 into main May 18, 2026
23 checks passed
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.

6 participants