The problem
When trying to run the integration tests for the slurmd charmed operator, our CI pipeline fails with the following stacktrace:
Traceback (most recent call last):
File "/home/runner/work/slurmd-operator/slurmd-operator/tests/integration/test_charm.py", line 48, in test_build_and_deploy
await asyncio.gather(
File "/home/runner/work/slurmd-operator/slurmd-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py", line 1820, in deploy
resources = await self.add_local_resources(application_name,
File "/home/runner/work/slurmd-operator/slurmd-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py", line 2052, in add_local_resources
data = p.read_text() if p.exists() else ''
File "/usr/lib/python3.10/pathlib.py", line 1135, in read_text
return f.read()
File "/usr/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
This error is raised when we try to attach our resource lbnl-nhc-1.4.3.tar.gz to the slurmd application. NHC (Node Health Check) is a utility for measuring the health of compute nodes in your cluster; it is commonly used to collect observability metrics. When we try to attach NHC, pathlib.Path(...).read_text(...) tries to decode the .tar.gz file as an utf-8 text file rather than a binary file. This causes python-libjuju to raise the above UnicodeDecodeError which then torpedoes our CI pipeline. The block of code below is what is responsible for this issue:
|
else: |
|
p = Path(path) |
|
data = p.read_text() if p.exists() else '' |
This could potentially be fixed by switch the implementation to pathlib.Path(...).read_bytes(...)
Steps to reproduce
- Assume that you already have a cloud and Juju controller set up...
git clone -b jaime/drop-focal-support git@github.com:jaimesouza/slurmd-operator.git
cd slurmd-operator
tox run -e integration
- Wait a few minutes...
- See stacktrace with
UnicodeDecodeError
The problem
When trying to run the integration tests for the slurmd charmed operator, our CI pipeline fails with the following stacktrace:
This error is raised when we try to attach our resource
lbnl-nhc-1.4.3.tar.gzto the slurmd application. NHC (Node Health Check) is a utility for measuring the health of compute nodes in your cluster; it is commonly used to collect observability metrics. When we try to attach NHC,pathlib.Path(...).read_text(...)tries to decode the .tar.gz file as an utf-8 text file rather than a binary file. This causes python-libjuju to raise the aboveUnicodeDecodeErrorwhich then torpedoes our CI pipeline. The block of code below is what is responsible for this issue:python-libjuju/juju/model.py
Lines 2050 to 2052 in 2581b0c
This could potentially be fixed by switch the implementation to
pathlib.Path(...).read_bytes(...)Steps to reproduce
git clone -b jaime/drop-focal-support git@github.com:jaimesouza/slurmd-operator.gitcd slurmd-operatortox run -e integrationUnicodeDecodeError