Install hooks fails with FileNotFoundError
gnuoy opened this issue · 2 comments
PR #137 has introduced a bug that causes the install hook to fail. If charm-env is not present on python3.6 (bionic) then FileNotFoundError is raised not CalledProcessError which install_or_update_charm_env does not catch https://github.com/juju-solutions/layer-basic/blob/master/lib/charms/layer/basic.py#L155
2019-07-20 08:14:51 DEBUG install Traceback (most recent call last): 2019-07-20 08:14:51 DEBUG install File "/var/lib/juju/agents/unit-masakari-1/charm/hooks/install", line 8, in <module> 2019-07-20 08:14:51 DEBUG install basic.bootstrap_charm_deps() 2019-07-20 08:14:51 DEBUG install File "lib/charms/layer/basic.py", line 131, in bootstrap_charm_deps 2019-07-20 08:14:51 DEBUG install install_or_update_charm_env() 2019-07-20 08:14:51 DEBUG install File "lib/charms/layer/basic.py", line 159, in install_or_update_charm_env 2019-07-20 08:14:51 DEBUG install '--version']).decode('utf8')) 2019-07-20 08:14:51 DEBUG install File "/usr/lib/python3.6/subprocess.py", line 356, in check_output 2019-07-20 08:14:51 DEBUG install **kwargs).stdout 2019-07-20 08:14:51 DEBUG install File "/usr/lib/python3.6/subprocess.py", line 423, in run 2019-07-20 08:14:51 DEBUG install with Popen(*popenargs, **kwargs) as process: 2019-07-20 08:14:51 DEBUG install File "/usr/lib/python3.6/subprocess.py", line 729, in __init__ 2019-07-20 08:14:51 DEBUG install restore_signals, start_new_session) 2019-07-20 08:14:51 DEBUG install File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child 2019-07-20 08:14:51 DEBUG install raise child_exception_type(errno_num, err_msg, err_filename) 2019-07-20 08:14:51 DEBUG install FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/sbin/charm-env': '/usr/local/sbin/charm-env' 2019-07-20 08:14:51 ERROR juju.worker.uniter.operation runhook.go:132 hook "install" failed: exit status 1
Also seeing this on charm which was building successfully before PR #137, and with no changes other than a newer layer-basic, the install hook in this reactive charm is failing due to missing charm-env
.
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 PyYAML-5.1.1 Tempita-0.5.2 charmhelpers-0.19.16 charms.reactive-1.2.1 netaddr-0.7.19 pip-8.1.2 pyaml-19.4.1 setuptools-39.0.1 setuptools-scm-1.17.0 six-1.12.0
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install Traceback (most recent call last):
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "/var/lib/juju/agents/unit-gitlab-0/charm/hooks/install", line 8, in <module>
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install basic.bootstrap_charm_deps()
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "lib/charms/layer/basic.py", line 131, in bootstrap_charm_deps
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install install_or_update_charm_env()
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "lib/charms/layer/basic.py", line 159, in install_or_update_charm_env
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install '--version']).decode('utf8'))
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install **kwargs).stdout
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "/usr/lib/python3.6/subprocess.py", line 423, in run
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install with Popen(*popenargs, **kwargs) as process:
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install restore_signals, start_new_session)
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install raise child_exception_type(errno_num, err_msg, err_filename)
unit-gitlab-0: 08:41:36 DEBUG unit.gitlab/0.install FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/sbin/charm-env': '/usr/local/sbin/charm-env'
unit-gitlab-0: 08:41:36 ERROR juju.worker.uniter.operation hook "install" failed: exit status 1
I can confirm that building the charm with layer-basic from #139 allows the install hook to run successfully and charm-env
is available as usual.