ops library 2.9.0 released: log forwarding config in Pebble layers, alignment of secrets with upcoming Juju, and unit testing actions

The Charm Tech team has just released version 2.8.0 of ops.

It’s available from PyPI by using pip install ops, which should pick up the latest version (pin with ops==2.9.0 if you want to pin to a specific version).

In addition to smaller improvements to docs and tests and some bug fixes, there are three changes to note:

Unit testing actions

Writing unit tests for actions with Harness is now as simple as:

def test_action(harness):
    out = harness.run_action("my-action-name", {"param1": value, "param2": value2})
    assert out.results == {"result1": "expected"}

Added in #1053

Secrets

In the original implementation of Juju secrets, the owner of a secret would automatically peek at secret contents - this also meant that using ‘refresh’ was not allowed. This behaviour causes difficulties in some situations, so is being changed in the next versions of Juju.

In ops, we are switching to the new behaviour. This primarily applies to Harness, which was updated in #1067, but also to the ops documentation. The constraints outside of Harness are applied by Juju, so your charms will reflect the new behaviour when Juju updates.

We’ve also fixed the simulated access to app secrets for non-leaders in #1076.

Pebble Log Targets

Pebble 1.4 added the ability to configure log forwarding for services to a Loki server, and Pebble 1.6 extends this with the ability to add custom labels to the forwarded logs. This functionality is now exposed in ops via a new (optional) log-targets section in Pebble layers and plans. Added in #1074

Read more in the full release notes on GitHub.

1 Like