Description
get_default_ip_config function from nettools slas has an issue that causes some services which depend on it to fail, most notably the admin_alerts_notifier
Detalis
KeyError 'address' raised from internal function _clean on machines that have tun interfaces, as the tun interface has no default mac address and the function expect the 'address' key to always exist.
$ more /sys/class/net/*/address | cat
::::::::::::::
/sys/class/net/br-43db53252048/address
::::::::::::::
02:42:00:dd:d2:7e
::::::::::::::
/sys/class/net/docker0/address
::::::::::::::
02:42:0f:ef:2f:53
::::::::::::::
/sys/class/net/enp2s0/address
::::::::::::::
54:48:10:d3:ea:08
::::::::::::::
/sys/class/net/lo/address
::::::::::::::
00:00:00:00:00:00
::::::::::::::
/sys/class/net/tun0/address
::::::::::::::
::::::::::::::
/sys/class/net/wlp3s0/address
::::::::::::::
d8:9c:67:2a:f2:53
TFTshop was generating this error on my local machine, Alerts support notifier service was failing because of this, if TFTshop, or any software that have JSNG as dependencies, runs on a machine that has TUN interface (or other virtual network interfaces with no mac address), some services could fail.
Steps to reproduce
on a machine with tun interface, e.g, you have yggdrasil installed, inside jsng shell do:
j.sals.nettools.get_default_ip_config()
2022-04-05 12:21:23.020 | ERROR | jumpscale.tools.errorhandler.errorhandler:_handle_exception:93 - KeyError: 'address'
Traceback/Logs/Alerts
this was taken from TFTshop logs
2022-04-05 01:20:58.640 | INFO | alerts_notifier:job:13 - Alerts support notifier service: service started
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
File "/home/sameh/projects/it_as_energy_shop/.venv/lib/python3.8/site-packages/jumpscale/packages/admin/services/alerts_notifier.py", line 19, in job
ip_info = j.sals.nettools.get_default_ip_config()
File "/home/sameh/projects/it_as_energy_shop/.venv/lib/python3.8/site-packages/jumpscale/sals/nettools/__init__.py", line 316, in get_default_ip_config
for nic in get_network_info():
File "/home/sameh/projects/it_as_energy_shop/.venv/lib/python3.8/site-packages/jumpscale/sals/nettools/__init__.py", line 383, in get_network_info
for nic in _get_info():
File "/home/sameh/projects/it_as_energy_shop/.venv/lib/python3.8/site-packages/jumpscale/sals/nettools/__init__.py", line 375, in _get_info
yield _clean(nic_info)
File "/home/sameh/projects/it_as_energy_shop/.venv/lib/python3.8/site-packages/jumpscale/sals/nettools/__init__.py", line 349, in _clean
"mac": nic_info["address"],
KeyError: 'address'
2022-04-04T23:20:58Z <Greenlet at 0x7f8e71f356a0: <bound method AlertsNotifier.job of <alerts_notifier.AlertsNotifier object at 0x7f8e71ed7190>>> failed with KeyError
Description
get_default_ip_config function from nettools slas has an issue that causes some services which depend on it to fail, most notably the admin_alerts_notifier
Detalis
KeyError 'address' raised from internal function _clean on machines that have tun interfaces, as the tun interface has no default mac address and the function expect the 'address' key to always exist.
TFTshop was generating this error on my local machine, Alerts support notifier service was failing because of this, if TFTshop, or any software that have JSNG as dependencies, runs on a machine that has TUN interface (or other virtual network interfaces with no mac address), some services could fail.
Steps to reproduce
on a machine with tun interface, e.g, you have yggdrasil installed, inside
jsngshell do:Traceback/Logs/Alerts
this was taken from TFTshop logs