Core: Services: Cable Guy: Fix DHCP Client marker being removed#3479
Conversation
Reviewer's GuideThis PR enhances the Cable Guy manager to preserve the DHCP client marker (0.0.0.0 Mode.Client) when interface state changes by introducing an include_dhcp_markers flag to interface retrieval methods, re-injecting missing DHCP markers in get_interfaces, and updating route execution to retain those markers. Sequence diagram for preserving DHCP client marker during route executionsequenceDiagram
participant Manager
participant Interface
participant Settings
Manager->>Manager: _execute_route(action, interface_name, route)
Manager->>Manager: get_interface_by_name(interface_name, include_dhcp_markers=True)
Manager->>Manager: get_ethernet_interfaces(include_dhcp_markers=True)
Manager->>Manager: get_interfaces(filter_wifi=True, include_dhcp_markers=True)
Manager->>Settings: get_saved_interface_by_name(interface)
alt DHCP marker missing in valid_addresses
Manager->>Manager: Add InterfaceAddress(ip="0.0.0.0", mode=AddressMode.Client)
end
Manager->>Interface: Update routes and managed state
ER diagram for DHCP marker preservation in NetworkInterface addresseserDiagram
NETWORKINTERFACE {
string name
}
INTERFACEADDRESS {
string ip
string mode
}
NETWORKINTERFACE ||--o{ INTERFACEADDRESS: has
INTERFACEADDRESS }|--|| ADDRESSMODE: mode
ADDRESSMODE {
enum Client
enum Unmanaged
}
Class diagram for updated Cable Guy manager interface methodsclassDiagram
class Manager {
+get_interface_by_name(name: str, include_dhcp_markers: bool = False): NetworkInterface
+get_interfaces(filter_wifi: bool = False, include_dhcp_markers: bool = False): List[NetworkInterface]
+get_ethernet_interfaces(include_dhcp_markers: bool = False): List[NetworkInterface]
+_execute_route(action: str, interface_name: str, route: Route): None
}
class NetworkInterface {
+name: str
+addresses: List[InterfaceAddress]
+routes: List[Route]
}
class InterfaceAddress {
+ip: str
+mode: AddressMode
}
class AddressMode {
<<enumeration>>
Client
Unmanaged
}
Manager --> NetworkInterface
NetworkInterface --> InterfaceAddress
InterfaceAddress --> AddressMode
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
9e389bc to
9e5ec67
Compare
|
we might need to backport this to 1.4 |
cfe7b07 to
5e58370
Compare
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Docstring for get_interfaces references include_dynamic_markers but the parameter is named include_dhcp_markers – please align names and descriptions.
- The new include_dhcp_markers flag in get_ethernet_interfaces is missing from its docstring parameters – please add it for clarity.
- Consider extracting the DHCP marker re-add logic from get_interfaces into a dedicated helper to reduce method complexity and improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Docstring for get_interfaces references include_dynamic_markers but the parameter is named include_dhcp_markers – please align names and descriptions.
- The new include_dhcp_markers flag in get_ethernet_interfaces is missing from its docstring parameters – please add it for clarity.
- Consider extracting the DHCP marker re-add logic from get_interfaces into a dedicated helper to reduce method complexity and improve readability.
## Individual Comments
### Comment 1
<location> `core/services/cable_guy/api/manager.py:472` </location>
<code_context>
return result
- def get_ethernet_interfaces(self) -> List[NetworkInterface]:
+ def get_ethernet_interfaces(self, include_dhcp_markers: bool = False) -> List[NetworkInterface]:
"""Get ethernet interfaces information
</code_context>
<issue_to_address>
Consider updating the docstring to mention the new include_dhcp_markers parameter.
The docstring should document the include_dhcp_markers parameter for clarity.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
def get_ethernet_interfaces(self, include_dhcp_markers: bool = False) -> List[NetworkInterface]:
"""Get ethernet interfaces information
=======
def get_ethernet_interfaces(self, include_dhcp_markers: bool = False) -> List[NetworkInterface]:
"""
Get ethernet interfaces information.
Args:
include_dhcp_markers (bool): If True, include DHCP marker interfaces in the returned list.
Returns:
List[NetworkInterface]: List of ethernet network interfaces.
"""
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
5e58370 to
74ed9a0
Compare
|
The code looks sane, but only @Williangalvani actually has the setup to reproduce the problem |
|
btw, there's a typo in the commit title: "cabel" -> "cable" |
* Make sure that when `_execute_route` is called it keeps the DHCP requisition IP marker `0.0.0.0` `Mode.Client` alive
74ed9a0 to
cd1ea97
Compare
Fixed the typo thanks. |
|
waiting for @Williangalvani test to merge |
Williangalvani
left a comment
There was a problem hiding this comment.
so this "joaomariolago/blueos-core:fix-removed-dhcp-marker" is actually the one I tested.
I'll test the backport now.
|
Should be move this to 1.4 ? |
It's already there: #3505 |
Make sure that when
_execute_routeis called it keeps the DHCP requisition IP marker0.0.0.0Mode.Clientalive if the link changed it's state somehow.Related to #3466
Summary by Sourcery
Preserve the DHCP client IP marker (0.0.0.0 Mode.Client) when link state changes by propagating a new include_dhcp_markers flag through interface retrieval methods and using it in route execution.
Bug Fixes:
Enhancements: