charm-helpers icon indicating copy to clipboard operation
charm-helpers copied to clipboard

hookenv.network_get does not handle exceptions on Juju 1.25.*

Open digitalrane opened this issue 7 years ago • 1 comments

Using hookenv.network_get fails on Juju 1.25.* with a FileNotFoundError exception. This is not handled by the error handling, leading to failed hooks when this function is used on juju 1.25.

2018-02-08 03:48:29 INFO upgrade-charm Traceback (most recent call last): 2018-02-08 03:48:29 INFO upgrade-charm File "/var/lib/juju/agents/unit-nrpe-lxc-46/charm/hooks/charmhelpers/core/hookenv.py", line 929, in inner_translate_exc2 2018-02-08 03:48:29 INFO upgrade-charm return f(*args, **kwargs) 2018-02-08 03:48:29 INFO upgrade-charm File "/var/lib/juju/agents/unit-nrpe-lxc-46/charm/hooks/charmhelpers/core/hookenv.py", line 1116, in network_get_primary_address 2018-02-08 03:48:29 INFO upgrade-charm stderr=subprocess.STDOUT).decode('UTF-8').strip() 2018-02-08 03:48:29 INFO upgrade-charm File "/usr/lib/python3.4/subprocess.py", line 607, in check_output 2018-02-08 03:48:29 INFO upgrade-charm with Popen(*popenargs, stdout=PIPE, **kwargs) as process: 2018-02-08 03:48:29 INFO upgrade-charm File "/usr/lib/python3.4/subprocess.py", line 859, in init 2018-02-08 03:48:29 INFO upgrade-charm restore_signals, start_new_session) 2018-02-08 03:48:29 INFO upgrade-charm File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child 2018-02-08 03:48:29 INFO upgrade-charm raise child_exception_type(errno_num, err_msg) 2018-02-08 03:48:29 INFO upgrade-charm FileNotFoundError: [Errno 2] No such file or directory: 'network-get'

digitalrane avatar Feb 08 '18 04:02 digitalrane

Similarly, it fails on versions of juju that have a network-get that does not support the -r option, per https://bugs.launchpad.net/postgresql-charm/+bug/1751105

stub42 avatar Feb 23 '18 08:02 stub42