canonical / hotsos

Software analysis toolkit. Define checks in high-level language and leverage library to perform analysis of common Cloud applications.
Apache License 2.0
30 stars 37 forks source link

jujud binary version check error #868

Closed dosaboy closed 2 months ago

dosaboy commented 2 months ago

I'm hitting the following sometimes:

2024-05-14 02:03:17,949 253975 ERROR hotsos.plugin.juju [-] requires.YRequirementTypeBinary.result raised the following
2024-05-14 02:03:17,949 253975 ERROR hotsos.plugin.juju [-] caught exception when running requirement: [Errno 8] Exec format error: 'sosreport-foo-00123-2024-04-29-qwhzott/var/lib/juju/tools/machine-70/jujud'
2024-05-14 02:03:17,949 253975 ERROR hotsos.plugin.juju [-] something went wrong while executing check has_affected_juju_binary
Traceback (most recent call last):
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/checks.py", line 152, in result
    result = self.fetch_item_result(item)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/checks.py", line 37, in fetch_item_result
    result = item.result
  File "/home/ubuntu/git/dosaboy/propertree/propertree/propertree2.py", line 343, in __getattribute__
    return super().__getattribute__(name)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/requires/requires.py", line 101, in result
    result = item.result
  File "/home/ubuntu/git/dosaboy/propertree/propertree/propertree2.py", line 343, in __getattribute__
    return super().__getattribute__(name)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/requires/common.py", line 178, in result
    return self._result
  File "/home/ubuntu/git/dosaboy/propertree/propertree/propertree2.py", line 343, in __getattribute__
    return super().__getattribute__(name)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/requires/common.py", line 19, in intercept_exception_inner
    return f(*args, **kwargs)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/requires/types/binary.py", line 52, in _result
    _result = items.package_version_within_ranges(binary, versions)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/ycheck/engine/properties/requires/types/apt.py", line 136, in package_version_within_ranges
    pkg_version = self.packaging_helper.get_version(pkg)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/plugins/juju/resources.py", line 250, in get_version
    return self.version
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/plugins/juju/resources.py", line 176, in version
    return self.machine.version
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/ubuntu/.local/pipx/venvs/hotsos/lib/python3.10/site-packages/hotsos/core/plugins/juju/resources.py", line 75, in version
    out = subprocess.check_output([self.agent_bin_path,
  File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'sosreport-foo-00123-2024-04-29-qwhzott/var/lib/juju/tools/machine-70/jujud'
pponnuvel commented 2 months ago

It's because the sosreport is from aarch64 (ARM), which obviously won't run x86-64.

W're attempting to exec juju --version to get the version which won't be possible.

We can probably get the info by reading the binary.