Skip to content

[Bug]: Refreshing a charm with local resources doesn't work #881

@phoevos

Description

@phoevos

Description

I'm working on an upgrade test for a Kubernetes charm, where I'd like to perform the following steps:

  1. Deploy published version of the charm
  2. Build charm from source
  3. Refresh using the locally built charm

Unfortunately, I haven't been able to use libjuju's refresh or local_refresh successfully.

Initially, I tried to run this:

# deploy published version of charm [...]
charm_under_test = await ops_test.build_charm(".")
image_path = METADATA["resources"]["tensorboard-controller-image"]["upstream-source"]
await ops_test.model.applications[APP_NAME].refresh(
    path=f"{charm_under_test}", resources={"tensorboard-controller-image": image_path}
)

The above produces the following error:

FAILED tests/integration/test_upgrade.py::test_upgrade - NotImplementedError: resources option is not implemented

Due to the above, I switched to local_refresh instead (using the same syntax), which resulted in the following error:

FAILED tests/integration/test_upgrade.py::test_upgrade - juju.errors.JujuAPIError: missing base name or channel not valid

The full stack trace is this:

Traceback (most recent call last):
  File "/home/phoevos/canonical/kubeflow/tensorboards/charms/tensorboard-controller/tests/integration/test_upgrade.py", line 81, in test_upgrade
    await ops_test.model.applications[APP_NAME].local_refresh(
  File "/home/phoevos/canonical/kubeflow/tensorboards/charms/tensorboard-controller/.tox/integration/lib/python3.8/site-packages/juju/application.py", line 835, in local_refresh
    await app_facade.SetCharm(
  File "/home/phoevos/canonical/kubeflow/tensorboards/charms/tensorboard-controller/.tox/integration/lib/python3.8/site-packages/juju/client/facade.py", line 483, in wrapper
    reply = await f(*args, **kwargs)
  File "/home/phoevos/canonical/kubeflow/tensorboards/charms/tensorboard-controller/.tox/integration/lib/python3.8/site-packages/juju/client/_client13.py", line 1638, in SetCharm
    reply = await self.rpc(msg)
  File "/home/phoevos/canonical/kubeflow/tensorboards/charms/tensorboard-controller/.tox/integration/lib/python3.8/site-packages/juju/client/facade.py", line 656, in rpc
    result = await self.connection.rpc(msg, encoder=TypeEncoder)
  File "/home/phoevos/canonical/kubeflow/tensorboards/charms/tensorboard-controller/.tox/integration/lib/python3.8/site-packages/juju/client/connection.py", line 628, in rpc
    raise errors.JujuAPIError(result)
juju.errors.JujuAPIError: missing base name or channel not valid

Looking at the local_refresh signature, I don't get how I could specify the base there. BTW, refreshing using the Juju CLI works.

Urgency

Annoying bug in our test suite

Python-libjuju version

2.9.42.4

Juju version

2.9.42

Reproduce / Test

N/A

Metadata

Metadata

Assignees

Labels

kind/bugindicates a bug in the project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions