Skip to content

Unable to upload .tar file as local resource to deployed charmed application #1000

@NucciTheBoss

Description

@NucciTheBoss

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:

python-libjuju/juju/model.py

Lines 2050 to 2052 in 2581b0c

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

  1. Assume that you already have a cloud and Juju controller set up...
  2. git clone -b jaime/drop-focal-support git@github.com:jaimesouza/slurmd-operator.git
  3. cd slurmd-operator
  4. tox run -e integration
  5. Wait a few minutes...
  6. See stacktrace with UnicodeDecodeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions