freifunkh / ansible

Here we store all Ansible roles and configs used for Freifunk Hannover.
MIT License
7 stars 3 forks source link

autoupdate_wg.py should handle 'no wg interfaces' #233

Closed 1977er closed 2 years ago

1977er commented 2 years ago

In case there are no wg interfaces, autoupdate_wg.py crashes:


Traceback (most recent call last):
 File "/home/auto/autoupdate_wg.py", line 156, in <module>
 File "/home/auto/autoupdate_wg.py", line 125, in wg_modify_peer
 File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/generic/wireguard.py", line 237, in __init__
 File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 348, in __init__
OSError: [Errno 24] Too many open files
1977er commented 2 years ago
Traceback (most recent call last):
 File "/home/auto/autoupdate_wg.py", line 156, in <module>
 File "/home/auto/autoupdate_wg.py", line 125, in wg_modify_peer
 File "/usr/lib/python3/dist-packages/pyroute2/netlink/generic/wireguard.py", line 237, in __init__
 File "/usr/lib/python3/dist-packages/pyroute2/netlink/nlsocket.py", line 388, in __init__
 File "/usr/lib/python3/dist-packages/pyroute2/netlink/nlsocket.py", line 968, in post_init
 File "/usr/lib/python3.9/socket.py", line 232, in __init__
OSError: [Errno 24] Too many open files
1977er commented 2 years ago

More incarnations of the same (I guess):

Traceback (most recent call last):
 File "/home/auto/autoupdate_wg.py", line 156, in <module>
   wg_modify_peer(key, iface)
 File "/home/auto/autoupdate_wg.py", line 125, in wg_modify_peer
   wg = WireGuard()
 File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/generic/wireguard.py", line 237, in __init__
   GenericNetlinkSocket.__init__(self)
 File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 348, in __init__
   self._ctrl_read, self._ctrl_write = os.pipe()
OSError: [Errno 24] Too many open files
AiyionPrime commented 2 years ago

We just discussed, wrapping this and having it fail silently is not an option; it would be preferable, if we just started the systemd-timer, that runs this after all WireGuard interfaces are up, if that's the issue.

https://github.com/freifunkh/ansible/blob/master/roles/ffh.mesh_wireguard_remotes_peers_git/templates/autoupdate_wg.py.j2

1977er commented 2 years ago

Fixed in 2f543a3680474297da83f33056a0588d15537f17.