Pure-Storage-Ansible / FlashArray-Collection

Ansible Collection for Pure Storage FlashArray
GNU General Public License v3.0
19 stars 21 forks source link

purefa_network fails to update interface if it has not IP address or gateway assigned with new version of netaddr #543

Closed tylergmuir closed 4 months ago

tylergmuir commented 4 months ago

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:

  1. Write a playbook that uses the purefa_network module that attempts to update something about the interface.
  2. Set the interface to have no IP address and no gateway assigned.
  3. 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.

sdodsley commented 4 months ago

TBH this feels like a bug in netaddr 1.0.0 as valid_ipv6 doesn't fail when passed None, but none the less we will add a fix.