Describe the bug
With the release of netaddr==1.0.0 they changed some of the logic in the valid_ipv4 function. This results in an error being thrown if None is passed to valid_ipv4 whereas previously it would have just returned false.
Starting on line 340 of the purefa_network module there is this block of code:
if not current_state["gateway"]:
if valid_ipv4(interface["address"]):
current_state["gateway"] = None
elif valid_ipv6(interface["address"]):
current_state["gateway"] = None
I'm not 100% sure the reason for this code since it seems to check if current_state["gateway"] is not true and then sets it to None if the address assigned to the interface is valid. But I believe that current_state["gateway"] would only ever be the gateway IP address or None. So the only time this code would be triggered is if current_state["gateway"] was already None.
Regardless, the error occurs when interface["address"] is None, causing an error to be thrown.
I believe this could be fixed by just removing the section I pointed out above, but since I am not sure of the function of the code in the first place, I wanted to just document the issue and let someone else take a look before opening a PR to remove the code.
To Reproduce
Steps to reproduce the behavior:
Write a playbook that uses the purefa_network module that attempts to update something about the interface.
Set the interface to have no IP address and no gateway assigned.
Run playbook and see error.
Expected behavior
The playbook should update the interface regardless of what the starting value was.
Additional context
This appears to only occur due to code changes in the upstream netaddr module in release 1.0.0. By downgrading the version of netaddr, the playbook functions as expected.
Describe the bug With the release of netaddr==1.0.0 they changed some of the logic in the
valid_ipv4
function. This results in an error being thrown ifNone
is passed tovalid_ipv4
whereas previously it would have just returned false.Starting on line 340 of the purefa_network module there is this block of code:
I'm not 100% sure the reason for this code since it seems to check if
current_state["gateway"]
is nottrue
and then sets it toNone
if the address assigned to the interface is valid. But I believe thatcurrent_state["gateway"]
would only ever be the gateway IP address orNone
. So the only time this code would be triggered is ifcurrent_state["gateway"]
was alreadyNone
.Regardless, the error occurs when
interface["address"]
isNone
, causing an error to be thrown.I believe this could be fixed by just removing the section I pointed out above, but since I am not sure of the function of the code in the first place, I wanted to just document the issue and let someone else take a look before opening a PR to remove the code.
To Reproduce Steps to reproduce the behavior:
Expected behavior The playbook should update the interface regardless of what the starting value was.
Additional context This appears to only occur due to code changes in the upstream
netaddr
module in release 1.0.0. By downgrading the version ofnetaddr
, the playbook functions as expected.