Recent Releases of ops
ops - 3.2.0: ops will log security events
With this release, Ops will send security event logs to Juju's log; for example, when there is a permission error getting relation or secret data. This is logged at TRACE level, so should not be noticeable in most cases, and is intended to be used in later work rather than by charms themselves.
A typing-only change has been made to support Pebble's new opentelemetry log target.
On the testing front, scenario now supports setting the JUJU_MACHINE_ID variable in the mocked environment.
Over the last month, we refreshed the Ops docs landing page, moved to documentation.ubuntu.com/ops, and removed the .html suffix from pages. We expect that this will be the last big renaming for the docs for a while now.
What's Changed
Features
- Add security event logging in https://github.com/canonical/operator/pull/1905
- Surface JUJUMACHINEID envvar in testing env in https://github.com/canonical/operator/pull/1961
- Add a new log target type opentelemetry in https://github.com/canonical/operator/pull/1937
Documentation
- Update links and config for switch to documentation.ubuntu.com/ops in https://github.com/canonical/operator/pull/1940
- Update the required Python version and note the 2.x documentation site in https://github.com/canonical/operator/pull/1946
- Be consistent with recommending self.config in https://github.com/canonical/operator/pull/1947
- Use latest styles from starter pack and remove .html extensions in https://github.com/canonical/operator/pull/1951
- Remove .html extensions from hardcoded links in https://github.com/canonical/operator/pull/1955
- Fix broken URLs in sitemap in https://github.com/canonical/operator/pull/1956
- Add related doc links to homepage in https://github.com/canonical/operator/pull/1959
- Use classes from ops instead of ops.
in https://github.com/canonical/operator/pull/1968 - Fix unstyled error pages in https://github.com/canonical/operator/pull/1969
- Add Google Analyics integration and cookie consent banner in https://github.com/canonical/operator/pull/1971
- Refresh docs homepage with more context about Ops in https://github.com/canonical/operator/pull/1964
- Update link to Charmlibs docs in https://github.com/canonical/operator/pull/1985
- Remove unnecessary pages from sitemap in https://github.com/canonical/operator/pull/1979
- Update the httpbin charm to jubilant in https://github.com/canonical/operator/pull/1987
- Update zero to hero to jubilant in https://github.com/canonical/operator/pull/1988
- Add model-config best practice note in https://github.com/canonical/operator/pull/1990
- Change some best practices to tips in https://github.com/canonical/operator/pull/2001
- Add integration test for invalid config in httpbin charm in https://github.com/canonical/operator/pull/2002
- Make a
Layerinstead of aLayerDictin the httpbin charm in https://github.com/canonical/operator/pull/2003 - Update how-to to feature Jubilant (1/2) in https://github.com/canonical/operator/pull/2000
- Use Charmcraft-style format and lint for example charms, not Ops-style in https://github.com/canonical/operator/pull/2008
- Update broken link to HookVars source code in https://github.com/canonical/operator/pull/2006
- Update how-to to feature Jubilant (2/2) in https://github.com/canonical/operator/pull/2004
CI
- Fixes for the sbom and secscan workflow, and trigger it on publishing in https://github.com/canonical/operator/pull/1916
- Store the charmcraft logs if packing fails in https://github.com/canonical/operator/pull/1936
- Install release dependencies for the TIOBE analysis in https://github.com/canonical/operator/pull/1930
- Add Juju 4/beta to the smoke test matrix in https://github.com/canonical/operator/pull/1963
- Adjust permissions block in publish workflow in https://github.com/canonical/operator/pull/1984
- Update actions/checkout to v5 in https://github.com/canonical/operator/pull/1993
- Enable doctests in https://github.com/canonical/operator/pull/1991
- Ignore juju/4 timeouts in https://github.com/canonical/operator/pull/1998
- Remove the token for SBOM and secscan on publish in https://github.com/canonical/operator/pull/2009
- Speed up integration test in https://github.com/canonical/operator/pull/1978
Full Changelog: https://github.com/canonical/operator/compare/3.1.0...3.2.0
- Python
Published by james-garner-canonical 6 months ago
ops - 2.23.1: Add the remote unit to Relation.data, but not Relation.units
This is a small bug-fix release for the 2.x series that addresses issues with the recent feature making relation data available in relation-departed events. Rather than inserting the remote unit into Relation.units, the data is available from Relation.data, without changing Relation.units.
What's Changed
Fixes
- Add the remote unit to
Relation.databut notRelation.unitsin https://github.com/canonical/operator/pull/1928
Documentation
- Be consistent with recommending
self.appandself.unitin https://github.com/canonical/operator/pull/1856 - Add notice about ops 2 and ops 3 in https://github.com/canonical/operator/pull/1867
- Update title and edit links for ops 2.23 docs in https://github.com/canonical/operator/pull/1885
CI
- Hotfix, publish job for ops-tracing in https://github.com/canonical/operator/pull/1865
Full Changelog: https://github.com/canonical/operator/compare/2.23.0...2.23.1
- Python
Published by tonyandrewmeyer 7 months ago
ops - 3.1.0: app_name and unit_id available from testing.Context
This release exposes the app name and unit ID in the testing Context. In addition, a number of bugs are fixed, particularly ones introduced with the recent change to exposing the relation data of departed units.
What's Changed
Features
- Release automation script in https://github.com/canonical/operator/pull/1855
- Add appname and unitid attributes to testing.context in https://github.com/canonical/operator/pull/1920
Fixes
- If an event ends with
_Abort(0)tests should behave as if it ended successfully in https://github.com/canonical/operator/pull/1887 - If
self.appis not actually set avoid a new crash location in https://github.com/canonical/operator/pull/1897 - Only add the remote unit for departed and broken relation events, fix ordering in https://github.com/canonical/operator/pull/1918
- Add the remote unit to
Relation.databut notRelation.unitsin https://github.com/canonical/operator/pull/1925
Documentation
- Use
load_configin the httpbin example charm in https://github.com/canonical/operator/pull/1852 - Update
HACKING.mdwith how to bump ops version in Charmcraft profiles in https://github.com/canonical/operator/pull/1872 - Change title of docs site in https://github.com/canonical/operator/pull/1890
- Use config and action classes in the Kubernetes tutorial in https://github.com/canonical/operator/pull/1891
- Reference example charms from K8s tutorial and fix consistency in https://github.com/canonical/operator/pull/1898
- Update style guide in https://github.com/canonical/operator/pull/1720
- Fix issues in how-to guide for stored state in https://github.com/canonical/operator/pull/1901
- Link out to the 12-factor tutorials from the tutorial index page in https://github.com/canonical/operator/pull/1902
- Replace broken link in testing explanation in https://github.com/canonical/operator/pull/1913
- Expand the storage how-to with content from juju docs scheduled for removal in https://github.com/canonical/operator/pull/1915
- Ops tracing how to in https://github.com/canonical/operator/pull/1853
- Add a security explanation doc in https://github.com/canonical/operator/pull/1904
Tests
- Replace Python version to 3.10 for observability charm tests in https://github.com/canonical/operator/pull/1914
CI
- Use httpbin demo charm for the
charmcraft packtest in https://github.com/canonical/operator/pull/1895 - Move TIOBE workflow to self-hosted runners in https://github.com/canonical/operator/pull/1912
- Add SBOM generation and secscan workflow in https://github.com/canonical/operator/pull/1906
- Build and publish in one step in https://github.com/canonical/operator/pull/1857
- Update the name and email when updating the charm pins in https://github.com/canonical/operator/pull/1924
- Drop smoke test against 20.04 in https://github.com/canonical/operator/pull/1923
Full Changelog: https://github.com/canonical/operator/compare/3.0.0...3.1.0
- Python
Published by tonyandrewmeyer 7 months ago
ops - Ops 3.0.0, ops-tracing 3.0.0 and ops-scenario 8.0.0 Require Python 3.10
This release removes support for Python 3.8 and Ubuntu 20.04, but is otherwise compatible with Ops 2. If you have a charm that needs to support Python 3.8, you can continue to use Ops 2, which will still receive security and critical bug fixes.
What's Changed
Documentation
- Be consistent with recommending self.app and self.unit in #1856
CI
- Hotfix, publish job for ops-tracing in #1865
Full Changelog: https://github.com/canonical/operator/compare/2.23.0...3.0.0
- Python
Published by IronCore864 8 months ago
ops - 2.23.0.post1
CI
- hotfix, publish job for ops-tracing in https://github.com/canonical/operator/pull/1865
Full Changelog: https://github.com/canonical/operator/compare/2.23.0...2.23.0.post1
- Python
Published by dimaqq 8 months ago
ops - Ops 2.23.0, ops-tracing 2.23.0 and ops-scenario 7.23.0 enhanced schema support and testing improvements
This release introduces enhancements focused on improving developer experience and code reliability. Key features include support for defining configuration, action, and relation data schemas using Python classes, streamlining data validation and reducing boilerplate. The release also enhanced testing and tracing capabilities, such as improved access to trace data and utilities for creating testing states, alongside several bug fixes addressing issues in relation handling, OpenTelemetry integration, and testing mocks.
This is the last feature release in the 2.x series, with only security and critical bugfixes in the future. Ops 3 will not support Python 3.8 and Ubuntu 20.04. Otherwise, Ops 3 will be backwards compatible with Ops 2.
What's Changed
Features
- Support for config schema as Python classes in https://github.com/canonical/operator/pull/1741
- Support for action parameter schema as Python classes in https://github.com/canonical/operator/pull/1756
- Ops[tracing] compatibility with jhack in https://github.com/canonical/operator/pull/1806
- Support for relation data schema as Python classes in https://github.com/canonical/operator/pull/1701
- Add CheckInfo.successes field and .has_run property in https://github.com/canonical/operator/pull/1819
- Provide a method to create a testing.State from a testing.Context in https://github.com/canonical/operator/pull/1797
- Expose trace data in testing in https://github.com/canonical/operator/pull/1842
- Add a helper to generate a Layer from rockcraft.yaml in https://github.com/canonical/operator/pull/1831
Fixes
- Correctly load an empty Juju config options map in https://github.com/canonical/operator/pull/1778
- Fix type annotation of container check_infos in ops.testing in https://github.com/canonical/operator/pull/1784
- Restrict the version of a dependency, opentelemetry-sdk in https://github.com/canonical/operator/pull/1794
- Remote unit data is available in relation-departed in https://github.com/canonical/operator/pull/1364
- Juju allows access to the remote app databag in relation-broken, so Harness should too in https://github.com/canonical/operator/pull/1787
- Don't use private OpenTelemetry API in https://github.com/canonical/operator/pull/1798
- Do not return this unit in a mocked peer relation in https://github.com/canonical/operator/pull/1828
- Testing.PeerRelation properly defaults to no peers in https://github.com/canonical/operator/pull/1832
- In meter-status-changed JUJU_VERSION is not set in https://github.com/canonical/operator/pull/1840
- Only provide the units belonging to the app in Relation.units in https://github.com/canonical/operator/pull/1837
Documentation
- Remove two best practices, and drop two to tips in https://github.com/canonical/operator/pull/1758
- Update link to Charmcraft for managing app config in https://github.com/canonical/operator/pull/1763
- Update link to Juju documentation for setting up deployment in https://github.com/canonical/operator/pull/1781
- Fix external OTLP link in https://github.com/canonical/operator/pull/1786
- Distribute the ops-scenario README content across the ops docs in https://github.com/canonical/operator/pull/1773
- Improve testing.errors.UncaughtCharmError message in https://github.com/canonical/operator/pull/1795
- In the "manage the charm version" how-to, give an example of using override-build in https://github.com/canonical/operator/pull/1802
- Small adjustments to the 'how to trace charm code' doc in https://github.com/canonical/operator/pull/1792
- Replace Harness example and fix links in README in https://github.com/canonical/operator/pull/1820
- Add httpbin charm from Charmcraft as an example charm in https://github.com/canonical/operator/pull/1743
- Fix on_collect mistake in sample code in https://github.com/canonical/operator/pull/1829
- Update code in K8s tutorial, with source in repo (part 2) in https://github.com/canonical/operator/pull/1734
- Update Loki section on charming zero-to-hero tutorial in https://github.com/canonical/operator/pull/1847
- Remove expandable boxes of text in https://github.com/canonical/operator/pull/1844
- Improve httpbin charm by removing defer() and adding collect_status in https://github.com/canonical/operator/pull/1833
- Move {posargs} to the end of pytest command lines in tox.ini in https://github.com/canonical/operator/pull/1854
CI
- Install the ops[tracing] dependencies for the TIOBE action in https://github.com/canonical/operator/pull/1761
- Add ops-scenario and ops-tracing as explicit installs for TIOBE in https://github.com/canonical/operator/pull/1764
- Persist credentials for update-charm-pins workflow in https://github.com/canonical/operator/pull/1766
- Stop smoke testing Charmcraft 2 in https://github.com/canonical/operator/pull/1782
- Use Charmcraft 3.x for smoke testing 20.04 and 22.04 in https://github.com/canonical/operator/pull/1821
- Enable xdist for the 'unit' tox environments in https://github.com/canonical/operator/pull/1830
Full Changelog: https://github.com/canonical/operator/compare/2.22.0...2.23.0
- Python
Published by IronCore864 8 months ago
ops - Ops 2.22.0, ops-tracing 2.22.0 and ops-scenario 7.22.0 tracing resource attributes for Juju topology
What's Changed
This release improves ops[tracing] by adding Juju topology resource attributes, including charm, juju_model, and juju_unit.
We've also documented how to access the Pebble metrics endpoint, which provides metrics for services and health checks in OpenMetrics format.
Features
- Add Juju topology labels in https://github.com/canonical/operator/pull/1744
Fixes
- Turn on databag access validation in
__init__in https://github.com/canonical/operator/pull/1737 - Allow event suffixes to appear in event names in
ops.testingin https://github.com/canonical/operator/pull/1754
Documentation
- Document how to manage metrics in https://github.com/canonical/operator/pull/1692
- Link to our docs from the top of our README in https://github.com/canonical/operator/pull/1710
- Update code in K8s tutorial, with source in repo (part 1) in https://github.com/canonical/operator/pull/1719
- Update links to juju.is/docs in https://github.com/canonical/operator/pull/1725
- Fix link in breakpoint output, remove link from Harness error message in https://github.com/canonical/operator/pull/1726
- Update Matrix channel name to Charm Tech in https://github.com/canonical/operator/pull/1740
- Rename configurations to configuration in https://github.com/canonical/operator/pull/1746
- Fix typos in code snippets by @MattiaSarti in https://github.com/canonical/operator/pull/1750
CI
- Add
ops[tracing]integration tests in https://github.com/canonical/operator/pull/1686 - Pin workflows by hash in https://github.com/canonical/operator/pull/1721
- Disable alertmanager compatibility tests until upstream fix in https://github.com/canonical/operator/pull/1745
- Remove explicit scopes and update HACKING.md in https://github.com/canonical/operator/pull/1748
- Pin trusted workflows by tag in https://github.com/canonical/operator/pull/1752
- Re-enable
alertmanager-k8s-operatorin observability charm tests in https://github.com/canonical/operator/pull/1753 - Fix reporting to TIOBE after
ops[tracing]addition in https://github.com/canonical/operator/pull/1755
New Contributors
- @MattiaSarti made their first contribution in https://github.com/canonical/operator/pull/1750
Full Changelog: https://github.com/canonical/operator/compare/2.21.1...2.22.0
- Python
Published by dwilding 9 months ago
ops - Ops 2.21.1, ops-tracing 2.21.1 and ops-scenario 7.21.1 reverting fresh charm instance for deferred events
What's Changed
This hot-fix release reverts the 2.21.0 change where separate charm class instances were used to run deferred events. That change was not compatible with a certain charming practice where custom upgrade code is run before event processing. We're reverting for now and will discuss with the charming teams what the way forward may be.
Reverted
- Reverting "run deferred events with fresh charm instances" in https://github.com/canonical/operator/pull/1711
Documentation
- Add best practices about status in https://github.com/canonical/operator/pull/1689
Full Changelog: https://github.com/canonical/operator/compare/2.21.0...2.21.1
- Python
Published by dimaqq 10 months ago
ops - Ops 2.21.0, ops-tracing 2.21.0 and ops-scenario 7.21.0 Native tracing support in ops and support for Pebble identities
What's Changed
This release adds ops[tracing], the first-party tracing support for your charms, support for reading and setting Pebble identities and a change where a new instance of the charm class is used for each deferred event.
Potential gotchas
Due to https://github.com/canonical/charmcraft/issues/2259, your charm may not build against 20.04 base, if you are using requirements.txt or other mechanism that enforces building all dependencies from source. Please wait for charmcraft 3.4 hot fix or migrate to the uv plugin. The issue is not unique to ops, however this release brings in a new dependency that is affected. If yours is a simple charm without complex charm libs, you may be able work around the issue by restricting your dependencies, like ops <= 2.20.0.
Each deferred event is now run in a fresh instance of your charm class. The change should be safe for most charms, however, if your charm defers events and shares data between the deferred event and the current event in the charm class, please test thoroughly. The Ops pre-commit and commit events are also now emitted after each deferred event, so if you use those and defer, please check that it's safe to have them run more than once per hook.
Features
- Opstracing in https://github.com/canonical/operator/pull/1612
- Pebble identities in https://github.com/canonical/operator/pull/1672
- Run deferred events with fresh charm instances in https://github.com/canonical/operator/pull/1631
Fixes
- Allow TLS 1.2 in ops-tracing in https://github.com/canonical/operator/pull/1705
- Try to fix flaky pebble exec test in https://github.com/canonical/operator/pull/1664
Documentation
- Add best practice note around using tooling provided by the charmcraft profile in https://github.com/canonical/operator/pull/1700
- Clarify guidance about designing python modules in https://github.com/canonical/operator/pull/1670
- Fix a bug in the k8s tutorial doc about unit test in https://github.com/canonical/operator/pull/1688
- Fix broken link in readme in https://github.com/canonical/operator/pull/1679
- Fix links to juju docs in https://github.com/canonical/operator/pull/1681
- Fix tox command in hacking.md in https://github.com/canonical/operator/pull/1661
- Improve landing page of kubernetes charm tutorial in https://github.com/canonical/operator/pull/1660
CI
- Add zizmor to static check github workflows in https://github.com/canonical/operator/pull/1656
- Change prerelease setting used to add latest ops and the testing API in https://github.com/canonical/operator/pull/1682
- Don't pin release jobs to github environments in https://github.com/canonical/operator/pull/1683
- Don't run tests within the publish job in https://github.com/canonical/operator/pull/1684
- Fix smoke test in https://github.com/canonical/operator/pull/1698
- Post-release versioning, release process update + workflow fix in https://github.com/canonical/operator/pull/1658
- Rename "tox -e fmt" to "tox -e format" in https://github.com/canonical/operator/pull/1668
Tests
- Fix overly specific test that fails sometimes with tracing in https://github.com/canonical/operator/pull/1695
Full Changelog: https://github.com/canonical/operator/compare/2.20.0...2.21.0
- Python
Published by dimaqq 10 months ago
ops - ops 2.20.0 and ops-scenario 7.20.0 remove_revision, remote_model, config metadata, custom events in testing, pebble layer merging fixes in testing, and docs improvements
What's Changed
This release of ops features a new remove_revision() convenience method to avoid working directly with revision numbers in secret-remove and secret-expired events. A new remote_model property has been added for Relation. The efficiency of RelationData.Content.update has also been improved, and the config metadata is now exposed in CharmMeta.
This ops-scenario release features the ability to emit custom events, as well as additional data verification and stronger immutability. Additionally, Pebble layer merging has been fixed, both in this package and in Harness.
Our documentation continues to improve. We migrated best practices from the Juju docs and made the Kubernetes charm tutorial shorter and more focused. We also reorganised the testing docs into a single how-to guide about unit testing and a more accessible explanation about testing in general.
Features
- Add a
remove_revision()method toSecretRemoveEventandSecretExpiredEventin https://github.com/canonical/operator/pull/1624 - Add
Relation.remote_modelproperty in https://github.com/canonical/operator/pull/1610 - Efficient implementation of
RelationDataContent.updatein https://github.com/canonical/operator/pull/1586 - Expose the config metadata in
CharmMetain https://github.com/canonical/operator/pull/1648 - Add the ability to emit custom events in unit tests in https://github.com/canonical/operator/pull/1589
- Check that the check-infos in
testing.Containermatch the plan in https://github.com/canonical/operator/pull/1630 ops.testing.Statecomponents are less mutable in https://github.com/canonical/operator/pull/1617
Fixes
- Assorted fixes for Pebble layer merging in Harness and Scenario in https://github.com/canonical/operator/pull/1627
Documentation
- Add a docs link to the Harness deprecation warning in https://github.com/canonical/operator/pull/1513
- Add best practices and a "manage charms" how-to in https://github.com/canonical/operator/pull/1615
- Add section about services with long startup time in https://github.com/canonical/operator/pull/1604
- Clarify how to use mounts in
ops.testing.Containerin https://github.com/canonical/operator/pull/1637 - Fix code snippet indentation in https://github.com/canonical/operator/pull/1649
- Fix Scenario example in https://github.com/canonical/operator/pull/1616
- Move hooks-based charm migration guide in https://github.com/canonical/operator/pull/1636
- Putting test into each chapter of the tutorial in https://github.com/canonical/operator/pull/1647
- Refactor how-to unit test according to comments in https://github.com/canonical/operator/pull/1642
- Refactor test docs to 1 explanation and 2 how-tos in https://github.com/canonical/operator/pull/1628
- Remove the charm-tech@lists.launchpad.net email address in https://github.com/canonical/operator/pull/1632
- Remove tutorial chapters that are covered by the how-to guide in https://github.com/canonical/operator/pull/1511
- Stack args vertically for long signature lines in https://github.com/canonical/operator/pull/1641
- Testing explanation in https://github.com/canonical/operator/pull/1635
- Unify charm test docs how to in https://github.com/canonical/operator/pull/1639
CI
- Exclude vault-k8s-operator until the system can handle monorepos in https://github.com/canonical/operator/pull/1650
- Use the latest version of ops-scenario in the compatibility tests in https://github.com/canonical/operator/pull/1608
Full Changelog: https://github.com/canonical/operator/compare/2.19.2...2.20.0
- Python
Published by james-garner-canonical 11 months ago
ops - ops 2.19.4 and ops-scenario 7.19.4 Synchronise ops and ops-scenario versions
No changes since 2.19.3 and 7.19.3. This is to push packages to PyPI only.
Full Changelog: https://github.com/canonical/operator/compare/2.19.3...2.19.4
- Python
Published by tonyandrewmeyer 12 months ago
ops - ops 2.19.3 and ops-scenario 7.19.3 Synchronise ops and ops-scenario versions
There are no changes from the previous release: this release is only to push the packages to PyPI, avoiding previous CI (and user-error) issues.
Full Changelog: https://github.com/canonical/operator/compare/2.19.2...2.19.3
- Python
Published by tonyandrewmeyer 12 months ago
ops - ops 2.19.2 and ops-scenario 7.19.2 Synchronise ops and ops-scenario versions
There are no changes since 2.19.1 and 7.19.1 -- the previous release failed CI so didn't reach PyPI, this just bumps the numbers to redo that.
Full Changelog: https://github.com/canonical/operator/compare/2.19.1...2.19.2
- Python
Published by tonyandrewmeyer 12 months ago
ops - ops 2.19.1 and ops-scenario 7.19.1 Synchronise ops and ops-scenario versions
The only change in this release is that ops[testing] is set to install exactly ops-scenario 7.19.1, and ops-scenario requires exactly ops 2.19.1.
There are no ops-scenario releases 7.3 through 7.18. These version numbers were skipped to have ops and ops-scenario in sync for minor and bugfix numbers.
Full Changelog: https://github.com/canonical/operator/compare/2.19.0...2.19.1
- Python
Published by tonyandrewmeyer 12 months ago
ops - ops 2.19.0 and ops-scenario 7.2.0 Enhanced Pebble checks, Juju version exposure, and improved documentation
What's Changed
This release of the Operator Framework introduces new features for managing Juju environments, including exposing the Juju version as Model.juju_version and enhanced control over Pebble checks. Several fixes address environment variables and improve the mocking capabilities. Extensive documentation updates provide clearer guidance on various topics, such as setting open ports and using Charmcraft. A special thanks to @medubelko for their first contribution to the project!
Features
- Expose the Juju version via Model objects in #1563
- Support starting and stopping Pebble checks, and the checks enabled field in #1560
Documentation
- Update logo and readme by @tmihoc in #1571
- Fill out remaining external link placeholders in #1564
- Use noun relation and verb integrate in #1574
- Update ref to charmcraft.yaml reference by @medubelko in #1580
- Add a how-to for setting open ports in #1579
- Fix links that pointed to earlier Juju docs in #1575
- Update links to Charmcraft docs in #1582
- Small updates to machine charm tutorial in #1583
CI
- Update list of charms and handle increasing uv usage in #1588
- Handle presence/absence of "static" and "static-charm" envs in #1590
New Contributors
- @medubelko made their first contribution in #1580
Full Changelog: https://github.com/canonical/operator/compare/2.18.1...2.19.0
- Python
Published by IronCore864 about 1 year ago
ops - ops-scenario 7.1.3 Put the mocked Juju environment into os.environ
What's Changed
In ops-scenario 7.1, the mocked Juju environment variables were placed directly in the _JujuContext object, rather than in os.environ as previously. We didn't announce this well, and agree that it's too significant a change to make in a minor release, so have reverted that change.
Fixes
- Expose the mocked Juju environment variables via os.environ again in https://github.com/canonical/operator/pull/1573
Documentation
- Update logo and readme by @tmihoc in https://github.com/canonical/operator/pull/1571
- Fill out remaining external link placeholders in https://github.com/canonical/operator/pull/1564
- Consistently use relation as the noun and integrate as the verb in https://github.com/canonical/operator/pull/1574
Full Changelog: https://github.com/canonical/operator/compare/2.18.1...scenario-7.1.3
- Python
Published by tonyandrewmeyer about 1 year ago
ops - ops 2.18.1 and ops-scenario 7.1.2 fixes for deferring and getting the Juju version in tests
What's Changed
Fixes an issue where deferring an event handler could cause another handler of the same event to fail, and one where reading the Juju version in unit tests would incorrectly result in 0.0.0 rather than the version set.
Fixes
- Ensure that the event snapshot is available when one observer defers and another does not in https://github.com/canonical/operator/pull/1562
- Put the Juju version in the environment as well as the JujuContext in https://github.com/canonical/operator/pull/1559
- Maintain transaction integrity on first run in https://github.com/canonical/operator/pull/1558
Documentation
- Set up intersphinx and add links by @tmihoc in https://github.com/canonical/operator/pull/1546
Full Changelog: https://github.com/canonical/operator/compare/2.18.0...2.18.1
- Python
Published by tonyandrewmeyer about 1 year ago
ops - ops 2.18.0 and ops-scenario 7.1.0
What's Changed
The Ops documentation has been dramatically revamped, with tutorials and how-to guides moved from Juju documentation to Ops where they belong, among with a myriad of other improvements.
The deferred event queue is now deduplicated, which should make charms feel more responsive.
Unit testing has been made faster by using an in-memory state database and a few other tricks.
Features
- Use :memory: as the unit state storage location for ops.testing in https://github.com/canonical/operator/pull/1494
- Don't store duplicate events in the notice queue in https://github.com/canonical/operator/pull/1372
- Make Context and Manager variadic types in testing by @Batalex in https://github.com/canonical/operator/pull/1445
Fixes
- Remove ops.main.main deprecation warning, and avoid warnings in action output in https://github.com/canonical/operator/pull/1496
- Require the same object to be in the testing state as in the event in https://github.com/canonical/operator/pull/1468
- Raise ModelError on unknown/error status set in Scenario in https://github.com/canonical/operator/pull/1417
Documentation
- Use the right ops-scenario for building the docs in https://github.com/canonical/operator/pull/1470
- Go full Diátaxis, ingesting the relevant juju.is/docs/sdk documentation by @tmihoc in https://github.com/canonical/operator/pull/1481
- Update how-to guides to use the new unit testing framework in https://github.com/canonical/operator/pull/1507
- Clearly deprecate Harness in the testing how-tos in https://github.com/canonical/operator/pull/1508
- Update boilerplate links in https://github.com/canonical/operator/pull/1515
- Fix Markdown syntax in ops.testing readme in https://github.com/canonical/operator/pull/1502
- Fix broken links and use cross references instead of absolute links in https://github.com/canonical/operator/pull/1519
- Use explicit framework param instead of *args in https://github.com/canonical/operator/pull/1523
- Add doc style tips to HACKING.md in https://github.com/canonical/operator/pull/1528
- Fix link to Juju docs in Kubernetes charm tutorial in https://github.com/canonical/operator/pull/1529
- Remove the publish badge from the README in https://github.com/canonical/operator/pull/1505
- Add how-to for storing state in https://github.com/canonical/operator/pull/1534
- Improve info about contributing to docs in https://github.com/canonical/operator/pull/1533
- Fix formatting errors in HACKING.md in https://github.com/canonical/operator/pull/1539
Continuous Integration
- All the ops-scenario publish actions need to be done in testing/ in https://github.com/canonical/operator/pull/1479
- Add support for injecting the latest ops when uv is used in https://github.com/canonical/operator/pull/1477
- Don't cancel other unit tests when one fails in https://github.com/canonical/operator/pull/1471
- Correctly point PyPI publishing to the ops-scenario packages in https://github.com/canonical/operator/pull/1514
- Use Concierge to set up the smoke test environments in https://github.com/canonical/operator/pull/1541
- Bump poetry to 2.0 to match downstream in https://github.com/canonical/operator/pull/1542
- Enable the prometheus-k8s revision updates again in https://github.com/canonical/operator/pull/1544
- Include Juju 2.9 in the smoke tests in https://github.com/canonical/operator/pull/1545
Testing
- Handle warnings generated by our own tests in https://github.com/canonical/operator/pull/1469
- Allow check to fail an additional time when running the test in https://github.com/canonical/operator/pull/1531
- Add a small set of ops.testing benchmark tests in https://github.com/canonical/operator/pull/1504
Refactoring
- Use ops.main.Manager in Scenario in https://github.com/canonical/operator/pull/1491
- Don't use the max-positional-args parent class for JujuLogLine in https://github.com/canonical/operator/pull/1495
- Cache signature structure in ops.testing state classes in https://github.com/canonical/operator/pull/1499
- Use _JujuContext in Scenario in https://github.com/canonical/operator/pull/1459
- Fix the testing src-layout structure and use relative imports in https://github.com/canonical/operator/pull/1431
Chores
- Bump version number for next ops release in https://github.com/canonical/operator/pull/1476
- Update and clarify release process in https://github.com/canonical/operator/pull/1478
- Temporarily disable TIOBE reporting in https://github.com/canonical/operator/pull/1510
- Remove file that seems to be accidentally committed in https://github.com/canonical/operator/pull/1509
- Update charm pins in https://github.com/canonical/operator/pull/1517
- Bump CI dependencies in https://github.com/canonical/operator/pull/1535
- Update documentation dependencies in https://github.com/canonical/operator/pull/1526
- Fix compatibility with ops-scenario 7.0.5 in https://github.com/canonical/operator/pull/1543
- Enable the scheduled TIOBE reporting again in https://github.com/canonical/operator/pull/1537
- Update charm pins in https://github.com/canonical/operator/pull/1540
- Bump actions/attest-build-provenance from 1.4.3 to 2.1.0 in https://github.com/canonical/operator/pull/1518
- Minor linting improvements to testing/src/scenario https://github.com/canonical/operator/pull/1456
- Remove compatibility code with older ops in testing in https://github.com/canonical/operator/pull/1418
- Use annotations from the
__future__in testing in https://github.com/canonical/operator/pull/1433
New Contributor
- Thank you, @Batalex for your first contribution!
- Thank you, Prints Charming (bot) for your contributions, and welcome to the team!
Full Changelog: https://github.com/canonical/operator/compare/2.17.1...2.18.0
- Python
Published by dimaqq about 1 year ago
ops - 2.17.1 Container.push_path() supports non-text files
What's Changed
This release fixes a bug with Container.push_path(). Previously, Container.push_path() required local files to be valid UTF-8 files. Container.push_path() now works on non-text files too.
Fixes
- Make
push_pathopen in binary mode so it works on non-text files (#1458)
Documentation
- Use
MaintenanceStatusfor local issues (#1397) - Explicitly document that
collect-statusis is run on every hook (#1399) - Use our docs URL for the
ogp:urlproperties Sphinx generates (#1411) - Set the
READTHEDOCScontext variable (#1410) - Fix Read the Docs ad placement (#1414)
- Clarify where
StoredStateis stored, and the upgrade behaviour (#1416) - Fix copy 'n' paste error in
stop_servicesdocstring (#1457)
Continuous Integration
- Configure the labels for dependabot PRs (#1407)
- Disable the automatic ops[testing] releasing (#1415)
- Use the actual poetry command, rather than manually tweaking the file (#1443)
- Fix broken GitHub variable expansion (#1446)
- Coverage report generation should also include testing/src/scenario (#1453)
- Fix PR title CI job concurrency (#1451)
- Adjust the release process to handle publishing ops and opstesting
- A better way than commenting out external repos (#1463)
- Use more descriptive names for the publish workflows (#1464)
- Move the XML coverage report to .report (#1465)
Refactoring
- Import the ops[testing] repository (#1406)
- Update linting with the latest ruff (#1441)
Full Changelog: https://github.com/canonical/operator/compare/2.17.0...2.17.1
- Python
Published by dwilding over 1 year ago
ops - 2.17.0: new unit testing API, and Secret fixes
What's Changed
This release adds a state-transition testing API for unit tests, formerly known as Scenario (many thanks to @PietroPasotti for his work developing and maintaining the library). Harness is still available, but we encourage all charmers to use the new API for unit tests going forward. The API is an optional install, for example: pip install ops[testing], so that the test API code does not get bundled into the charms. All of the classes that you would previously find when using ops-scenario in the scenario namespace can then be found in ops.testing. For example:
```python from ops import testing
ctx = testing.Context(MyCharm) state = ctx.run(ctx.on.start(), testing.State(leader=True)) assert state.unit_status == testing.ActiveStatus() ```
There are also two improvements to Juju Secrets: firstly, the .id of a Secret will always include the model UUID, so it can be reliably used for cross-model relations. A more significant change is that, previously, if a charm called set_contents() and set_info() in the same hook (even if not the same event handler, or in a deferred event handler) only the last call would have any effect. This is now changed so that the calls accumulate - you can set both content and metadata in the same hook, and also if you set_contents() twice the contents will be combined. The Juju team intend to make this the secret-set behaviour in the future as well.
Additionally, ops.main is now type hinted correctly and will no longer require a type: ignore directive from users!
Features
- Optionally install Scenario with
ops[testing]and expose the names in ops.testing in #1381 - Change ops.main() so that you don't need to
type: ignoreit in #1345 - Expand the secret ID out to the full URI when only given the ID in #1358
- Add a JujuVersion property for Pebble log forwarding to Loki in #1370
- Pre-emptively raise
InvalidStatusErrorinstead of waiting for Juju:- Make it an error to call
CollectStatusEvent.add_statuswith error or unknown in #1386 - Document and validate settable status values in
_ModelBackend.set_statusin #1354
- Make it an error to call
Fixes
- Fix type of
StatusBasesubclasses by callingStatusBase.registerin__init_subclass__in #1383 Secret.set_infoandSecret.set_contentcan be called in the same hook in #1373
Documentation
- Add top-level intro and module-level intros in #1320
- Update the links to the Pebble docs in #1362
- Note about repeatedly setting secret value in Juju 3.6 in #1366
config-changedis triggered by Juju trust in #1357- Typo on
CharmBaseinheritance example by @theofpa in #1349 - Docs: move Pebble to a separate page in #1392
Continuous Integration
- Periodically run the unit tests of all GitHub-hosted published charms in #1365
- Update the TIOBE reporting for the changes in coverage calculation in #1367
- Spell-check the code as part of linting in #1388
- Run the smoke tests on a schedule in #1387
Testing
- Fix tests that leaked environment variables in #1385
Refactoring
- Move the content of
ops.testingtoops._private.harnessin #1369 - Keep the
unittest.mocknames in the 'mock' namespace in #1379 - Deprecate
StatusBase.registerdecorator in #1384
Chores
- Note Juju version on legacy workaround in #1355
- Re-enable test now that Pebble directory permissions are fixed in #1363
- Generate warnings for events that will be removed in Juju 4.0 in #1374
New Contributors
- @theofpa made their first contribution in https://github.com/canonical/operator/pull/1349
Full Changelog: https://github.com/canonical/operator/compare/2.16.1...2.17.0
- Python
Published by james-garner-canonical over 1 year ago
ops - 2.16.1 Don't have Harness alter os.environ
This is a small bug-fix release to address a regression in ops 2.16.0 where creating a Harness object would add a JUJU_VERSION to os.environ.
Fixes
- Don't alter os.environ in Harness in https://github.com/canonical/operator/pull/1359
Full Changelog: https://github.com/canonical/operator/compare/2.16.0...2.16.1
- Python
Published by tonyandrewmeyer over 1 year ago
ops - 2.16.0
This release adds a private _JujuContext dataclass used to parse all JUJU_*` environment variables in one place; besides, a significant amount of work has been done on tests, continuous integration and documentation.
Features
- Add the description field to SecretInfo in https://github.com/canonical/operator/pull/1338
Refactor
- Parse JUJU_* env in one place in https://github.com/canonical/operator/pull/1313
Fixes
- Juju passes the expiry in a field 'expiry', not 'expires' in https://github.com/canonical/operator/pull/1317
- Correct the signature of .events() in https://github.com/canonical/operator/pull/1342
Documentation
- Security policy change to only support each active major release in https://github.com/canonical/operator/pull/1297
- Add example Juju version markers in https://github.com/canonical/operator/pull/1311
- Use Sphinx 8 in https://github.com/canonical/operator/pull/1303
- Live reload with sphinx-autobuild in https://github.com/canonical/operator/pull/1323
Tests
- Update the smoke test series/bases in https://github.com/canonical/operator/pull/1318
- Run pytest in parallel with pytest xdist in https://github.com/canonical/operator/pull/1319
- Bump pyright to 1.1.377 in https://github.com/canonical/operator/pull/1332
- Run tests on Py 3.12 and install test on Py 3.13 in https://github.com/canonical/operator/pull/1315
CI
- Add a workflow that runs the TIOBE quality checks in https://github.com/canonical/operator/pull/1301
- Allow executing the TIOBE workflow manually in https://github.com/canonical/operator/pull/1321
- Make Pyright report unnecessary type ignore comments in https://github.com/canonical/operator/pull/1333
- Enable linting of docs/custom_conf.py in https://github.com/canonical/operator/pull/1330
New Contributors
Thanks @james-garner-canonical for your first contributions, and welcome to the team!
Full Changelog: https://github.com/canonical/operator/compare/2.15.0...2.16.0
- Python
Published by IronCore864 over 1 year ago
ops - 2.15.0 Support Pebble check-failed and check-recovered events
What's Changed
This release adds support for new events based on Pebble checks. As of Juju 3.6b2, when a Pebble check reaches the failure threshold, a PebbleCheckFailedEvent will be emitted - and when the check starts passing again, the charm will get a PebbleCheckRecoveredEvent. Kubernetes charms can observe these events to react to failing checks - for example, change the unit or application status, output additional logging, or dynamically adjust the workload to work around the failure.
- Add support for Pebble check-failed and check-recovered events in https://github.com/canonical/operator/pull/1281
Fixes
- Pass secret data to Juju via files, rather than as command-line values in https://github.com/canonical/operator/pull/1290
- Include checks and log targets when merging layers in ops.testing by @amandahla in https://github.com/canonical/operator/pull/1268
Documentation
- Clarify distinction between maintenance and waiting status in https://github.com/canonical/operator/pull/1148
CI
- Bump the Go version to match Pebble in https://github.com/canonical/operator/pull/1285
- Run ruff format over charm pin update code in https://github.com/canonical/operator/pull/1278
- Bump certifi from 2024.2.2 to 2024.7.4 in /docs in https://github.com/canonical/operator/pull/1282
- Update charm pins in https://github.com/canonical/operator/pull/1269
New Contributors
- @amandahla made their first code contribution in #1268
Full Changelog: https://github.com/canonical/operator/compare/2.14.1...2.15.0
- Python
Published by dimaqq over 1 year ago
ops - 2.14.1 Fix a possible Pebble exec hang and minor other fixes
What's Changed
No new features with this release, but it includes a significant fix for Pebble exec to avoid hanging when Pebble is unable to respond quickly.
We've also corrected the Harness behaviour when working with secrets when the secret does not exist or the charm does not have permission to view/modify it, and also expanded the API reference documentation for secrets.
Fixes
- Add connect timeout for exec websockets to avoid hanging in https://github.com/canonical/operator/pull/1247
- Adjust Harness secret behaviour to align with Juju in https://github.com/canonical/operator/pull/1248
Tests
- Fix TypeError when running test.pebble_cli in https://github.com/canonical/operator/pull/1245
- Properly clean up after running setuprootlogging in test_log in https://github.com/canonical/operator/pull/1259
- Verify that defer() is not usable on stop,remove,secret-expired,secret-rotate in https://github.com/canonical/operator/pull/1233
Documentation
- Fix HACKING.md link on PyPI, and internal links in https://github.com/canonical/operator/pull/1261 and https://github.com/canonical/operator/pull/1236
- Add a section to HACKING.md on PR titles (commit messages to main) in https://github.com/canonical/operator/pull/1252
- Add release step to update pinned charm tests in https://github.com/canonical/operator/pull/1213
- Add a security policy in https://github.com/canonical/operator/pull/1266
- Add ops.main to API reference in https://github.com/canonical/operator/pull/1273
CI
- Only run tests once on push to PR in https://github.com/canonical/operator/pull/1242
- Validate PR title against conventional commit rules in https://github.com/canonical/operator/pull/1262
- Only update ops, not all dependencies, in charm tests in https://github.com/canonical/operator/pull/1275
- Add artefact attestation in https://github.com/canonical/operator/pull/1267
Thanks go to the members of the Canonical security teams who helped out putting the security policy together!
Full Changelog: https://github.com/canonical/operator/compare/2.14.0...2.14.1
- Python
Published by tonyandrewmeyer over 1 year ago
ops - 2.14.0 Fix RelationDataContent.update, add ActionFailed.__str__
This release fixes the RelationDataContent.update method to follow dict.update semantics, that is to allow another dict, an iterable, keyword arguments or a mixture thereof.
Features
- feat: add a
__str__to ActionFailed, for better unexpected failure output in https://github.com/canonical/operator/pull/1209
Fixes
- The
otherargument toRelatationDataContent.update(...)should be optional by @addyess in https://github.com/canonical/operator/pull/1226
Documentation
- Use the actual emoji character rather than GitHub markup, to show properly on PyPI in https://github.com/canonical/operator/pull/1221
- Clarify that SecretNotFound may be raised for permission errors in https://github.com/canonical/operator/pull/1231
Refactoring
- Refactor tests to pytest style in https://github.com/canonical/operator/pull/1199 https://github.com/canonical/operator/pull/1200 https://github.com/canonical/operator/pull/1203 https://github.com/canonical/operator/pull/1206
- Use
ruffformatter and reformat all code in https://github.com/canonical/operator/pull/1224 - Don't use f-strings in logging calls in https://github.com/canonical/operator/pull/1227 https://github.com/canonical/operator/pull/1234
New Contributors
- @dimaqq made their first contribution in https://github.com/canonical/operator/pull/1217. Thanks @dimaqq for your first contributions, and welcome to the team!
- @addyess made their first contribution in https://github.com/canonical/operator/pull/1226
Full Changelog: https://github.com/canonical/operator/compare/2.13.0...2.14.0
- Python
Published by dimaqq almost 2 years ago
ops - 2.13.0 Testing User Secrets with Harness and Other Improvements
The main feature this release is the ability to work with user secrets (secrets that a Juju admin adds to the model) in Harness. You'll want to start with the new add_user_secret() method and from there can mostly manage them in the same way as application secrets.
Note that one of the fixes corrects the type of config values, which were previously strongly typed as str, when they may be int, float, bool, or str. This may break your existing type checks, although we have endeavoured to reach out preemptively with PRs to address this where possible.
Features
- Add support for user secrets in Harness in https://github.com/canonical/operator/pull/1176
- Add
pebble.CheckInfo.change_idfield in https://github.com/canonical/operator/pull/1197
Fixes
- Correct the model config types in https://github.com/canonical/operator/pull/1183
- In Harness, only inspect the source file if it will be used - this fixes using Harness in a Python REPL in https://github.com/canonical/operator/pull/1181
Documentation
- Update publishing a release in HACKING.md in https://github.com/canonical/operator/pull/1173
- Add
tox -e docs-depsto compile requirements.txt in https://github.com/canonical/operator/pull/1172 - Update doc to note deprecated functionality in https://github.com/canonical/operator/pull/1178
Tests
- First stage of converting tests from unittest to pytest in https://github.com/canonical/operator/pull/1191, https://github.com/canonical/operator/pull/1192, https://github.com/canonical/operator/pull/1196, https://github.com/canonical/operator/pull/1193, and https://github.com/canonical/operator/pull/1195
Full Changelog: https://github.com/canonical/operator/compare/2.12.0...2.13.0
- Python
Published by tonyandrewmeyer almost 2 years ago
ops - 2.12.0 Support getting cloud specs via the credential-get hook tool, and other improvements.
This release adds a new model method, get_cloud_spec, that returns information about the cloud where the charm is deployed. This may also include credentials that can be used by the charm to interact directly with the cloud, where Juju does not yet provide sufficient modelling. If your charm is currently using the credential-get tool directly, you can now make use of this native support in ops. Note that this functionality is only available on machine charms.
Features
- Added
Model.get_cloud_specwhich uses thecredential-gethook tool to get details of the cloud where the model is deployed https://github.com/canonical/operator/pull/1152
Fixes
- Add a consistency check and default network to
add_relationby @PietroPasotti in https://github.com/canonical/operator/pull/1138 - Warn when an observer weakref is lost by @PietroPasotti in https://github.com/canonical/operator/pull/1142
- Update Pebble Notices
get_noticesparameter name tousers=all(previouslyselect=all) https://github.com/canonical/operator/pull/1146 - More robust validation of observer signatures https://github.com/canonical/operator/pull/1147
- Fix attaching storage in Harness before
beginhttps://github.com/canonical/operator/pull/1150 - Change
Model.relation.apptype fromApplication|NonetoApplicationhttps://github.com/canonical/operator/pull/1151 - Fixed an issue where
pebble.Client.execmight leak asocket.timeout(builtins.TimeoutError) exception https://github.com/canonical/operator/pull/1155 - Don't special-case
get_relationbehaviour inleader-electedhttps://github.com/canonical/operator/pull/1156 - Accept
type: secretfor config options by @jameinel in https://github.com/canonical/operator/pull/1167
Refactoring
- Refactor main.py, creating a new
_Managerclass by @PietroPasotti in https://github.com/canonical/operator/pull/1085
Documentation
- Use "integrate with" rather than "relate to" https://github.com/canonical/operator/pull/1145
- Updated code examples in the docstring of
ops.testingfrom unittest to pytest style https://github.com/canonical/operator/pull/1157 - Add peer relation details in
Harness.add_relationdocstring https://github.com/canonical/operator/pull/1168 - Update Read the Docs Sphinx Furo theme to use Canonical's latest styling https://github.com/canonical/operator/pull/1163, https://github.com/canonical/operator/pull/1164, https://github.com/canonical/operator/pull/1165
New Contributors
Thanks @IronCore864 for your first contributions, and welcome to the team!
Full Changelog: https://github.com/canonical/operator/compare/2.11.0...2.12.0
- Python
Published by IronCore864 almost 2 years ago
ops - 2.11.0 Marking additional events as non-defer()able, and other minor improvements
This release marks additional events as not suitable for deferring: StopEvent, RemoveEvent, and the LifecycleEvents: CollectStatusEvent, CommitEvent, and PreCommitEvent. The defer() method on these event classes is marked as NoReturn and calling it will raise a RuntimeError.
Features
- feat: add the action's ID to the ActionEvent object in https://github.com/canonical/operator/pull/1124
- feat: add the ability to compare two Plan objects with == and create a Plan from a dict in https://github.com/canonical/operator/pull/1134
- feat: only have a
defer()method on events that can be deferred in https://github.com/canonical/operator/pull/1122
Fixes
- fix(testing): set JUJUREMOTEAPP and allow fetching relation data in relation-broken in https://github.com/canonical/operator/pull/1130
Documentation
- docs: tweak the wording around can_connect() usage in https://github.com/canonical/operator/pull/1123
Tooling
- chore: move to ruff for linting in https://github.com/canonical/operator/pull/1120
- chore: adjust isort to be more compatible with ruff in https://github.com/canonical/operator/pull/1139
- chore: expand ruff rule sets and make corresponding minor adjustments in https://github.com/canonical/operator/pull/1114
Full Changelog: https://github.com/canonical/operator/compare/2.10.0...2.11.0
- Python
Published by tonyandrewmeyer almost 2 years ago
ops - 2.10.0 Pebble custom notices, adjustments to relation-broken, and more
This release adds support for Pebble custom notices, including in the Harness testing framework, and removes the broken relation from the model's relations list when in the relation-broken event. There's also the usual collection of documentation improvements, bug fixes, and other minor improvements.
Pebble Notices
Pebble now includes a subsystem called Notices, each of which has a type and a key (currently the only type is "custom"). Custom notices allow the workload to wake up the charm when something interesting happens with the workload, for example, when a PostgreSQL backup process finishes, or some kind of alert occurs.
Workloads can run pebble notify to record an occurrence of a custom notice, providing a unique key and optional data, and Juju will trigger a PebbleCustomNotice event on the charm for it to take appropriate action.
Support for Pebble Notices is available from Juju 3.4.0 onwards. Read the docs about how to use custom notices from the workload container.
Relation-Broken
When a charm is handling a relation-broken event, the relation is on the verge of being removed. A common pattern in charms is to iterate through Model.relations (to generate a configuration file, for example), and the broken relation should not be included with the active relations. To simplify charm code, Model.relations now excludes the broken relation. The relation is still accessible via the event's .relation attribute, and all Relation objects now have an .active attribute to distinguish between the broken relation (active == False) and other relations (active == True).
The plan is that this change will also appear when using the Juju hook tools directly in a future version of Juju.
This does not change accessing the relation data during relation-broken, and this does not change any behaviour in relation-departed.
Features
- feat: support for Pebble Notices in https://github.com/canonical/operator/pull/1086 and in https://github.com/canonical/operator/pull/1100
- feat: add Relation.active, exclude inactive relations from Model.relations in https://github.com/canonical/operator/pull/1091
- feat: when handling actions, print uncaught exceptions to stderr in https://github.com/canonical/operator/pull/1087
- feat: model error on testing module if invalid status set by charm by @yanksyoon in https://github.com/canonical/operator/pull/1107
- feat: add support for v2 fields in CharmMeta in https://github.com/canonical/operator/pull/1106
Fixes
- fix: add pebble log targets and checks to testing plan by @PietroPasotti in https://github.com/canonical/operator/pull/1111
- fix(charm): make collect-status a LifeCycleEvent to avoid logging it by @PietroPasotti in https://github.com/canonical/operator/pull/1080
Documentation
- docs: update README.md in light of changes to
charmcraft initoutput by @tmihoc in https://github.com/canonical/operator/pull/1089 - docs: document limitations with pushing locked or bind-mount files in https://github.com/canonical/operator/pull/1094
- docs: add instructions on how to use a custom version of ops in a Charm in https://github.com/canonical/operator/pull/1092
Tooling
- build: migrate to pyproject.toml in https://github.com/canonical/operator/pull/1068
- ci: use a trusted publisher token for publishing to PyPI in https://github.com/canonical/operator/pull/1061
- fix(typing): update to latest version of Pyright and fix errors in https://github.com/canonical/operator/pull/1105
Many thanks to @PietroPasotti, @yanksyoon, and @tmihoc for their contributions to this release!
Full Changelog: https://github.com/canonical/operator/compare/2.9.0...2.10.0
- Python
Published by tonyandrewmeyer about 2 years ago
ops - 2.9.0: Pebble log forwarding, unit testing actions, and more
This release makes it easy to write tests for your Charm actions, aligns testing secrets with upcoming Juju changes, and exposes the ability to use the new Pebble log forwarding functionality. There's also the usual collection of documentation improvements, bug fixes, and other minor improvements.
Unit Testing Actions
Writing unit tests for actions with Harness is now as simple as:
python
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 (get the latest revision) at secret contents - this also meant that using 'refresh' was not allowed (since there was no revision tracking). This behaviour causes difficulties in some situations, so is being changed in the next versions of Juju (back to 3.1.7), removing the automatic peek and allowing refresh.
In ops, we are switching to the new behaviour, and this applies regardless of the detected/set JujuVersion. 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.
Note that you can get the old behaviour by always using refresh=True if that's what you prefer (to support both old and new Juju, you'll need to wrap this so that in older Juju you retry when it complains that you can't refresh).
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
Documentation Improvements
- A fresh README that's simpler and better aligns with the docs and other projects in the Juju universe in #1052 - many thanks to @tmihoc for this contribution!
- Clarified how custom events are emitted in
emit()in #1072 - Fixed the
Harness.get_filesystem_rootexample in the docs in #1065
Minor Improvements
- Removed the executable bit from all the .py files by in #1059 - thanks @jameinel!
- The test suite now passes under Python 3.12 in #1081
Fixes
- The SQLite storage file is no longer group/other readable. We strongly recommend against storing any secret data in stored state (use secrets), but we are aware of cases of this in the wild. This change prevents other users in the containers from being able to access the saved state file. Existing storage files will be
chmod'd to 0o600 whenopsfirst opens them after upgrading to 2.9.0+. #1057 - When parsing a timestamp returned from Pebble, there was a 1 in 2 million chance that
opswould fail with aValueError. Fixed in #1084 Container.push_pathandHarness.list_fileswould fail if the files/folders involved belonged to a user or group ID that did not have a name (for example, had been removed). Fixed in #1082. Thanks to @nedbat for the report!
Full Changelog: https://github.com/canonical/operator/compare/2.8.0...2.9.0
- Python
Published by tonyandrewmeyer about 2 years ago
ops - 2.8.0: Unit.reboot, RelationMeta.optional, and type-checked tests
This release includes a few small improvements: a new function Unit.reboot() (for machine charms only), the "optional" attribute of relations in metadata.yaml is now available in the RelationMeta object, and if the Pebble socket is missing (for example, if the container has just rebooted) we provide a clearer exception:
- feat: add
Unit.rebootfor machine charms in #1041 - feat: add
RelationMeta.optionalin #1038 - feat: provide a clearer exception when the Pebble socket is missing in #1049
We fixed a couple of small issues:
- fix:
push_pathandpull_pathinclude empty directories in #1024 - fix: reset collected statuses in
Harness.evaluate_statusin #1048
We've also made a few small improvements to the documentation:
- docs: note that status changes are immediate in #1029
- docs: add note to
ActionEvent.set_resultsabout maximum size in #1047 - docs: document more of the exceptions that may be raised in #1044
- docs: make
pebble.Client.remove_pathandContainer.remove_pathdocs consistent in #1031 - docs: update the PyPI development status to production/stable in #1020
Finally, we wrapped up our work on #1007, so the test suite is now fully type checked, did a couple of other minor type hinting improvements, and broke out the 'real' Pebble tests into a separate file for more clarity (you can still just run tox -e pebble):
- test: add type hints to test_testing in #1017
- test: add type hints to test_model in #1015
- test: add type hints to test_charm in #1022
- test: add type hints to test_storage in #1023
- test: add type hints to test_framework in #1025
- test: add type hints to test_main in #1028
- test: add type hints to pebble-related tests in #1030
- test: separate the real pebble tests into a separate module in #1018
- chore: remove as much 'if typing.TYPE_CHECKING:' as possible in #1034
- feat: narrow the type for 'app' and 'unit' in relation events by in #1032
Full Changelog: https://github.com/canonical/operator/compare/2.7.0...2.8.0
- Python
Published by tonyandrewmeyer over 2 years ago
ops - 2.7.0: Unit.set_ports(), and minor docs, CI, and test improvements
This release includes one new feature, a new function Unit.set_ports() to declare which ports should be open. We recommend using this method rather than managing multiple Unit.open_port() and Unit.close_port() calls:
- feat: add Unit.set_ports() for declarative port opening #1005
We've also made a few small improvements to the documentation:
- docs: reduce the amount of detail in the open/close port methods in #1006
- docs: remove 'you' and 'your' from docstrings in #1003
- docs: minor cleanup of the HACKING doc in #1016
Finally, we've also made a start expanding our type hinting to cover the test suite, and made a couple of minor improvements/fixes to our CI:
- test: add type hints to the test_infra tests in #1008
- test: add type hints to test_log tests by in #1009
- test: fix type hinting on test_jujuversion tests in #1011
- test: fix type hint warnings in test_private tests in #1012
- test: add type hinting to test_lib by in #1012
- test: add type hinting to test_helpers in #1014
- ci: use Go 1.20 for real Pebble tests in #1004
- ci: re-enable integration tests with mysql-*operator by in #1013
(Thanks @tonyandrewmeyer for your first contributions, and welcome to the team!)
Full Changelog: https://github.com/canonical/operator/compare/2.6.0...2.7.0
- Python
Published by tonyandrewmeyer over 2 years ago
ops - 2.6.0: Harness.handle_exec, Harness.add_relation improvements, and more
This release has two significant improvements to testing.Harness:
- Add
Harness.handle_execto allow charm tests to simulateContainer.execcalls (Pebble one-shot commands) and provide expected output. Thanks @weiiwang01 for the design and implementation (PR 993). - Simplify adding relation units and relation data by adding
app_dataandunit_dataparameters toHarness.add_relation. Previously, charm tests would have to calladd_relationfollowed byadd_relation_unitandupdate_relation_data-- now only a singleadd_relationcall is required. Implemented in PR 994.
In addition, several small improvements and fixes are included:
- feat(model): add
Secret.unique_identifier(XID part); improve id/label docs in https://github.com/canonical/operator/pull/986 - fix(testing): ignore
push()encoding if source is a binary file or stream in https://github.com/canonical/operator/pull/991 - fix(pebble): remove use of deprecated
cgimodule in Pebble code in https://github.com/canonical/operator/pull/996 - fix(model): ensure Secret.get_content returns a copy of the dict in https://github.com/canonical/operator/pull/1000
- fix(model): make Secret.set_content invalidate local cache by in https://github.com/canonical/operator/pull/1001
See all changes from 2.5.0 to 2.6.0.
- Python
Published by benhoyt over 2 years ago
ops - 2.5.1: Fix str vs bytes issue with testing push()
This is a patch fix on top of 2.5.0 to fix #990: "TypeError: write() argument must be str, not bytes" in Container.push under Harness.
- Python
Published by benhoyt over 2 years ago
ops - 2.5.0: Collect-status, Harness.get_filesystem_root, Pebble service context
This release includes three significant additions:
- Multi-status: An initial version of the much-discussed "multi-status" handling in the form of the new
collect_app_statusandcollect_unit_statusevents. This is useful for letting the framework automatically evaluate application (or unit) status from various components of the charm. We'll be documenting this properly soon, but in the meantime, read the API reference docs onCollectStatusEvent. PR #954. - Harness.getfilesystemroot: Overhauling the
Harness's test filesystem from an in-memory filesystem to use a temp directory on the real filesystem; useHarness.get_filesystem_rootto get the temp filesystem directory for a specific container. This makes testing container filesystem operations significantly easier and allows tests to use the regular Python file APIs to interact with it. Thanks @weiiwang01 for his efforts on this in #960. - Service context: Added support for Pebble's new "service context" feature, to allow you to exec commands in the context of a specified service (where context means environment variables, working directory, and user/group). PR #957.
Other notable changes:
- Add
JujuVersion.supports_open_port_on_k8sby @carlcsaposs-canonical in PR #965 - Support reading
charmcraft.yamlin the testing harness by @syu-w in PR #977
In addition, the following developers made their first contribution:
- @paulomach in https://github.com/canonical/operator/pull/975 (Add kill-delay to pebble ServiceDict type)
- @sobolevn in https://github.com/canonical/operator/pull/978 (Replace typing.AnyStr with Union[str, bytes])
- @syu-w in https://github.com/canonical/operator/pull/977 (Support reading charmcraft.yaml in testing harness)
We also made several other minor improvements to type annotations and a few other tweaks. See the full changelog: https://github.com/canonical/operator/compare/2.4.1...2.5.0
- Python
Published by benhoyt over 2 years ago
ops - 2.4.1: Add type annotation for PebbleReadyEvent.workload
This is a patch release: a minor but important type annotation forgotten in 2.4.0. Without it, charms that use type annotation on the pebble-ready events will fail type checking, because attributes of the workload won't be available as Pyright/MyPy doesn't know the type.
Fix in https://github.com/canonical/operator/pull/962.
- Python
Published by benhoyt over 2 years ago
ops - 2.4.0: Improvements to API docs and type annotations
This release has no new functionality, but includes various improvements to API docs (docstrings) and type annotations, as well as a couple of minor bug fixes. Our API reference docs on Read The Docs look nicer, are more consistent, and have better types.
One change that may affect charms that use type checking: the new ops.X syntax will now work with type checkers (Pyright and MyPy) due to adding an explicit __all__ to ops/__init__.py (#937). Oh, and we fixed a bug with relative paths in Container.push_path -- thanks @yanksyoon!
See the full list of PRs merged below.
What's Changed
- Lock docs dependencies; build docs with recent Sphinx version by @benhoyt in https://github.com/canonical/operator/pull/938
- Explicitly add all public ops.X names to
__all__in__init__.pyby @benhoyt in https://github.com/canonical/operator/pull/937 - Use Canonical-ish theme from canonical/sphinx-docs-starter-pack by @benhoyt in https://github.com/canonical/operator/pull/941
- Use PurePath type annotation when path casted to string by @carlcsaposs-canonical in https://github.com/canonical/operator/pull/946
- Update Pyright version to latest (1.1.313) by @benhoyt in https://github.com/canonical/operator/pull/944
- Fix sphinx-build warnings and turn warnings into errors by @benhoyt in https://github.com/canonical/operator/pull/942
- Reinstate alertmanager-k8s-operator CI tests now that issue is fixed by @benhoyt in https://github.com/canonical/operator/pull/951
- Remove jargon from and simplify README by @benhoyt in https://github.com/canonical/operator/pull/950
- Fix issue with relative paths in
Container.push_pathby @yanksyoon in https://github.com/canonical/operator/pull/949 - Avoid error in FileInfo repr due to permissions being None by @benhoyt in https://github.com/canonical/operator/pull/956
- Various docstring and type annotation updates by @benhoyt in https://github.com/canonical/operator/pull/953
- Add "-> None" to methods without other types by @benhoyt in https://github.com/canonical/operator/pull/961
New Contributors
- @carlcsaposs-canonical made their first contribution in https://github.com/canonical/operator/pull/946
Full Changelog: https://github.com/canonical/operator/compare/2.3.0...2.4.0
- Python
Published by benhoyt over 2 years ago
ops - 2.3.0: Fix planned_units to exclude dying
This release includes only one minor functional changes: a fix to Application.planned_units to exclude dying units from the total (#936).
Also included is a type annotation fix to an internal testing method (#926).
To use this version, update the ops line in your requirements.txt to ops==2.3.0.
- Python
Published by benhoyt almost 3 years ago
ops - 1.5.5: Backport "error" status fix to 1.5
This releases the backport of the "error" status fix #875 to the 1.5-maintenance branch (PR #927).
- Python
Published by benhoyt almost 3 years ago
ops - 2.2.0: Harness.add_network, simplified "import ops"
This is version 2.1.0 of ops, which includes the following changes:
Harness.add_network
In #846 we added Harness.add_network, which allows developers who write charm unit tests to easily add simulated data for the bind address and network information. This is a small but long-requested feature that will avoid charmers patching internal ops methods. Fixes #456.
Simplified way to import ops
In #910 we added a simplified way to import ops: it pulls most of the names in the various ops.foo sub-modules into the top-level ops module so that charmers don’t have to remember which sub-module each class comes from. This also makes the various ops classes more discoverable with an IDE’s autocomplete. Fixes #731.
Other minor changes
There are also a few other minor changes, including the addition of Layer.__eq__ to allow you to compare pebble.Layer objects with the == operator. See the full list of commits in this release.
- Python
Published by benhoyt almost 3 years ago
ops - 2.1.1 (fixes install issues with 2.1.0)
This patch release fixes issues with the missing requirements.txt file during pip install: https://github.com/canonical/operator/pull/914.
- Python
Published by benhoyt almost 3 years ago
ops - 2.1.0
This is version 2.1.0 of ops, which includes the following changes:
Open-port support
We added Pythonic APIs to interface to the open-port, close-port, and opened-ports hook tools in PR #905. This allows charms to ask Juju to open ports in VM charms and in K8s sidecar charms (with some issues in the latter being fixed in https://github.com/juju/juju/pull/15225). See the Unit.open_port() API reference.
Other minor changes
- Use f-strings (almost) everywhere (#889)
- Un-vendor websocket library (#891) -- thanks @tinvaan
- A few minor tweaks now that we're on Python 3.8 (#890)
- Define all dependences in requirements files (#894) -- thanks @tinvaan
- Make testing pull() raise pebble.PathError and improve docs (#897)
- Don't call secret-info-get with both ID and label (#900)
- Add ops.lib deprecation notice (#901)
- Add debug logging for custom events (#843) -- thanks @PietroPasotti
- Replace "# type: T" comments with proper variable type annotations (#904)
View the full list of commits between 2.0.0 and 2.1.0.
- Python
Published by benhoyt almost 3 years ago
ops - 2.0.0 final
This is version 2.0.0 of ops, which includes the following changes:
Major changes
- APIs to interact with Juju Secrets, along with a testing harness. Read the tutorial or the code (#861).
- Ops 2.0.0 requires Python 3.8+ (ops 1.5.x works down to Python 3.5). Note that Python 3.8 is the version installed by default on Ubuntu 20.04 (Focal), where Python 3.5 was installed on Ubuntu 16.04 (Xenial). As a result, ops 2.0.0 is intended for use with Juju 3.0+, which only supports Ubuntu 20.04 and above. We started using some Python 3.8 features in #871, and plan to use more in future ops 2.x releases.
- Removed
SIMULATE_CAN_CONNECTfrom the testing harness (#871). When we introducedcan_connectit would have been a breaking change to enable it by default, so we added theSIMULATE_CAN_CONNECTglobal to enable it, with a warning that we'd enable it by default in a future release. This release removes the global flag and enables simulation by default. - Made
begin_with_initial_hooks()trigger pebble-ready in the testing harness (#871). The default value ofcontainer.can_connect()is still False when usingbegin()("manual mode"), but this release updatesbegin_with_initial_hooks()to setcan_connectto True and fire pebble-ready for all containers in the charm's metadata.
Note that the SIMULATE_CAN_CONNECT and begin_with_initial_hooks() changes won't change or break your charms, however, they may break charm tests -- for example, tests that aren't expecting pebble-ready to be fired when calling begin_with_initial_hooks().
Other breaking changes
- Deprecate controller storage: #882. This deprecate
use_juju_for_storage=True(it's intended for pod-spec charms). - Remove Windows support: #872. Juju 3.0 no longer supports Windows deployments, so ops doesn't need to either.
Minor changes
- Fix logging in can_connect, add tests; remove pebble.Error methods: #860. This fixes a couple of logging calls, but also removes the
name()andmessage()methods from theops.pebble.Errorexception subclass. This is theoretically a breaking change, but it is very unlikely these methods were used by charms. - Add ErrorStatus #875. This adds a missing unit status value,
error. - Add Pebble idempotency behavior #876. This makes the testing harness's emulated versions of
start()andstop()match Pebble's current behaviour, which makes them idempotent:start()now does nothing if the service is already started, and similarlystop()does nothing if the service is already stopped. - Clarifies the warning message when local storage is chosen: "not a Kubernetes podspec charm" instead of "not a kubernetes charm" (the latter is incorrect). This was done in #882.
- Removes the long-deprecated
keyargument to charm's__init__. This was done in #882. - Removes the deprecated (and private!)
Harness._oci_resourcesattribute. This was done in #882.
- Python
Published by benhoyt about 3 years ago
ops - 2.0.0rc2
This is a release candidate for the next major release of ops (2.0.0, which we plan to release late January). To try it in your charms, please update the ops line in your requirements.txt file to say:
ops==2.0.0rc2
For details of the changes since 1.x, see the 2.0.0 final release notes.
- Python
Published by benhoyt about 3 years ago
ops - 1.5.4
This is a patch release with only a few minor changes, including:
- Made harness.charm raise before begin (@PietroPasotti in #838)
- Use Storage.index instead of deprecated Storage.id (@benhoyt in #854)
- Add JujuVersion.has_secrets() (@beliaev-maksim in #855)
- Reinstate reversion of addrelationunit ValueError to warning (@benhoyt in #856)
See the full list of commits here.
The next release will likely be 2.0.0 with Juju secrets support, and switching from minimum Python version 3.5 to 3.8.
- Python
Published by benhoyt over 3 years ago
ops - 1.5.3
What's Changed
This is a bug-fix/patch release for ops 1.5 advancing the Operator Framework in a number of key areas including:
Typing
Typing is now complete for all ops modules and static checks for all using pyright.
- Typing framework.py by @PietroPasotti in https://github.com/canonical/operator/pull/772
- Typed ops.pebble.py by @PietroPasotti in https://github.com/canonical/operator/pull/773
- Typing charm.py by @PietroPasotti in https://github.com/canonical/operator/pull/791
- Fix model types by @PietroPasotti in https://github.com/canonical/operator/pull/810
- Typing main by @PietroPasotti in https://github.com/canonical/operator/pull/811
- Typed
ops/testing.pyby @PietroPasotti in https://github.com/canonical/operator/pull/828
Documentation
Various documentation improvements.
- Update docs for unset param in update_config by @swalladge in https://github.com/canonical/operator/pull/768
- cleaned up logging output by @PietroPasotti in https://github.com/canonical/operator/pull/797
- Fix docstring by @zmraul in https://github.com/canonical/operator/pull/802
- Added further documentation to define_event function in framework.py #830 by @nishant-dash in https://github.com/canonical/operator/pull/831
- Documented and checked ActionEvent.set_results with "Stdout" key by @PietroPasotti in https://github.com/canonical/operator/pull/809
- doc fix for config-changed by @PietroPasotti in https://github.com/canonical/operator/pull/804
Testing
The Harness now tries harder to behave like production code would.
- Make Harness more strict in validating relation data contents (on write) by @PietroPasotti in https://github.com/canonical/operator/pull/786
- Address storage testing quirks by @rwcarlsen in https://github.com/canonical/operator/pull/763
- fixed issues with relation data read by @PietroPasotti in https://github.com/canonical/operator/pull/795
- Remove overzealous Harness.add_storage error check. by @rwcarlsen in https://github.com/canonical/operator/pull/781
- added config backend to simulate more closely juju's own by @PietroPasotti in https://github.com/canonical/operator/pull/787
- Include departing unit info for harness-initiated events by @rwcarlsen in https://github.com/canonical/operator/pull/790
Improved error reporting
- Improved error message for invalid storage key usage by @rwcarlsen in https://github.com/canonical/operator/pull/771
- Better error for relation data access in relation-broken events by @rwcarlsen in https://github.com/canonical/operator/pull/765
- downgrade breaking-change exception to just a warning by @rwcarlsen in https://github.com/canonical/operator/pull/822
Bugfixes
- Fix incorrect kwarg handling in testing backend storage_list by @rwcarlsen in https://github.com/canonical/operator/pull/820
- Allow network-get to return hostnames where previously IPaddr were expected by @PietroPasotti in https://github.com/canonical/operator/pull/823
- Use --file for relation-set; avoid shell argument length limits by @rbarry82 in https://github.com/canonical/operator/pull/805
- Fixed bug in ops.Model where non-string keys could be used to write relation data by @PietroPasotti in https://github.com/canonical/operator/pull/788
Misc
- Added a very basic smoke test. Run it with
tox -e smokeby @pengale in https://github.com/canonical/operator/pull/800 - require tests to pass on a commit before we publish it to pypi by @rwcarlsen in https://github.com/canonical/operator/pull/815
- Remove harcoded value for self.model_uuid by @Abuelodelanada in https://github.com/canonical/operator/pull/782
- Test observe(decorated-method) by @PietroPasotti in https://github.com/canonical/operator/pull/808
New Contributors
- @swalladge made their first contribution in https://github.com/canonical/operator/pull/768
- @zmraul made their first contribution in https://github.com/canonical/operator/pull/802
- @nishant-dash made their first contribution in https://github.com/canonical/operator/pull/831
Full Changelog: https://github.com/canonical/operator/compare/1.5.2...1.5.3
- Python
Published by jnsgruk over 3 years ago
ops - 1.5.2
This is a bug-fix/patch release for ops 1.5 addressing a few important issues including:
- Fix harness model uuid to use the correct/current format used by juju (#782).
- Include the missing departing unit attribute on relation-departed events when using the harness (#790).
- Remove restrictive limits on the number and size of relation data items that can be set (#805).
- Fix type annotations that were causing failures in Ubuntu xenial based environments - i.e. python 3.5 (#810).
Notably, this release was carefully crafted to not break your code. If it does - please complain loudly and we will address problems after completing a good, forceful facepalm.
- Python
Published by rwcarlsen over 3 years ago
ops - 1.5.0
The Operator Framework team is proud to release version 1.5.0 of the Operator Framework! This is a modestly sized release with a few new, non breaking features.
Highlights
- Harness support for simulating storage mounts during testing - allowing disk IO to mounted filepaths and sharing data between shared mounts in charm and workload (via e.g. pebble operations) containers. This should "just work" - as long as you use the storage mount paths provided via e.g.
self.model.storages['storage-name'][0].locationwhich you should already be doing anyway (right?). - New
Container.push_pathandContainer.pull_pathmethods for recursively pushing/pulling directories to/from workload containers. - We've begun to implement complete type annotations to improve auto-completion and robustness. Over the next release or so type annotation coverage will continue to improve.
Complete List of Changes
- Modify Harness.set_leader to be more robust, less finicky by @rwcarlsen in https://github.com/canonical/operator/pull/733
- Harness add_layer merge support. by @alesstimec in https://github.com/canonical/operator/pull/738
- Edited test charm to support metadata v2, drop untested v1 fields by @pengale in https://github.com/canonical/operator/pull/748
- Harness: support mocking storage mounts by @rwcarlsen in https://github.com/canonical/operator/pull/734
- More typing by @PietroPasotti in https://github.com/canonical/operator/pull/744
- Typing for storage.py by @PietroPasotti in https://github.com/canonical/operator/pull/749
- Fixes address info value getter by @PietroPasotti in https://github.com/canonical/operator/pull/757
- Typing utils by @PietroPasotti in https://github.com/canonical/operator/pull/755
- PR template. by @pengale in https://github.com/canonical/operator/pull/746
- Typing for model.py by @PietroPasotti in https://github.com/canonical/operator/pull/756
- Recursively push+pull files/dirs to containers by @rwcarlsen in https://github.com/canonical/operator/pull/754
New Contributors
- @alesstimec made their first contribution in https://github.com/canonical/operator/pull/738
Full Changelog: https://github.com/canonical/operator/compare/1.4.0...1.5.0
- Python
Published by rwcarlsen over 3 years ago
ops - 1.4.0
The Operator Framework team is proud to release version 1.4.0 of the Operator Framework!
This is largely a bugfix release, but it also includes a few small, non breaking features.
Highlights
- Memory efficient push of file(s) to pebble
- Testing harness more closely matches live environment behavior
- Added flag to test with "real pebble". Use this to write tests that use an actual running Pebble rather than a fixture
- Add Container.isdir and Container.exists helpers
Complete List of Changes
- Memory-efficient push via pebble by @Vultaire in https://github.com/canonical/operator/pull/666
- remove_path succeeds even if path does not exist by @sed-i in https://github.com/canonical/operator/pull/677
- Make the storage harness work when metadata keys have hyphens by @rbarry82 in https://github.com/canonical/operator/pull/680
- docfix: mention
add_relation_unitin the docstring foradd_relationby @sed-i in https://github.com/canonical/operator/pull/683 - conformed list_files behaviour on failure with pebble's by @PietroPasotti in https://github.com/canonical/operator/pull/686
- Add real pebble tests to our CI by @rwcarlsen in https://github.com/canonical/operator/pull/687
- FIX remove_path docstring to relfect current behaviour. by @Abuelodelanada in https://github.com/canonical/operator/pull/698
- Fix incorrect variadic arg wrangling in get_services by @rwcarlsen in https://github.com/canonical/operator/pull/702
- add tox config for real pebble tests by @rwcarlsen in https://github.com/canonical/operator/pull/704
- skip broken ipython version to fix CI by @rwcarlsen in https://github.com/canonical/operator/pull/710
- Add Container.isdir and Container.exists helpers by @rwcarlsen in https://github.com/canonical/operator/pull/709
- Added notes on cutting a release to HACKING.md by @pengale in https://github.com/canonical/operator/pull/714
- Avoid issuing relation_changed events with no data delta by @mmanciop in https://github.com/canonical/operator/pull/705
- Updated docs on planned units. by @pengale in https://github.com/canonical/operator/pull/716
- expose the departing unit on RelationDeparted events by @rwcarlsen in https://github.com/canonical/operator/pull/712
- DEPATING -> DEPARTING by @PietroPasotti in https://github.com/canonical/operator/pull/717
- Implement send-signal for harness by @sed-i in https://github.com/canonical/operator/pull/715
- notes about documentation for contributers by @rwcarlsen in https://github.com/canonical/operator/pull/720
- Fixing updated link in docstrings by @Abuelodelanada in https://github.com/canonical/operator/pull/722
- Harness: add test for an empty config file by @sed-i in https://github.com/canonical/operator/pull/728
- beginwithinitial_hooks now sets post install status correctly by @pengale in https://github.com/canonical/operator/pull/727
- Add checks config fields and get_checks API by @benhoyt in https://github.com/canonical/operator/pull/668
- Memory-efficient pull via pebble by @Vultaire in https://github.com/canonical/operator/pull/667
New Contributors
- @PietroPasotti made their first contribution in https://github.com/canonical/operator/pull/686
- @rwcarlsen made their first contribution in https://github.com/canonical/operator/pull/687
- @Abuelodelanada made their first contribution in https://github.com/canonical/operator/pull/698
Full Changelog: https://github.com/canonical/operator/compare/1.3.0...1.4.0
- Python
Published by pengale almost 4 years ago
ops - ops 1.3.0
The Operator Framework team is proud to release version 1.3.0 of the Operator Framework!
OF 1.3.0 adds support for running one-shot commands via Pebble with the Container.exec method. This functionality uses the new Pebble “exec” API, which behaves similarly to lxd exec or kubectl exec – the Pebble CLI has a corresponding pebble exec command. The tool allows an operator to run a one-off command inside the workload container. It is very useful for troubleshooting, as well as performing maintenance tasks that haven’t yet been formalized as an action in a charm.
This release also includes a change to juju debug-code. The command now stops on all events and hooks, allowing charm authors to enter a debugging session without needing to specify a specific hook in advance. Charm authors can still access the old behavior by explicitly calling juju debug-code --at .
OF 1.3.0 adds a mocked out filesystem to the testing harness. Charm authors can now attach and detach virtual storage, and read and write files to the test filesystem. This feature has been long requested, and allows for much more complete unit test coverage for charms.
Additionally, the charmed operator framework now exposes a “planned unit count,” to allow charms to handle HA config and similar features that require a peer count in advance of the peers actually coming online. The information supplied by this feature, comprising a single int that represents the number of peers (inclusive of the current unit) an application is expected to have, is intentionally minimalist. Charm authors should use this feature to save unnecessary execution of HA setup in an environment that doesn’t need it (or unnecessary non HA setup in an environment that does). Code paths using the feature should understand that the int can change, and that it does not include a guarantee that the units will be available. (If there is a deploy issue with a unit, for example, the planned unit count will not be reached until a human operator intervenes and resolves the issue.)
Beyond these highlights, 1.3.0 includes many minor features and bugfixes. A complete list follows:
Features:
Include task logs in ChangeError.str (#653) Add support for storage to the testing harness. Add sendsignal to pebble.Client and model.Container (#669) Add a test for restarting Pebble services on older Pebble versions (#658) Add storage details to storage events # Added support for One-shot commands #593 Added “planned unit count” to model. #597 Add support for the new wait-change API #595 Let ‘debug-code’ catch all events by default #565 Flatten nested dictionaries passed to actionset() #630 Add pebble replan, support serverside restart. #580 Added storage mappings to ContainerMeta as ContainerStorageMeta #601 Remove ops.relation module #606 (Requires/Provides functionality now lives in a library.) Expose model uuid in ops.model.Model #563 Expose ‘limit’ in RelationMeta and improve ‘scope’ #552 Add user/group fields to Service (layer configuration) #540 Add eq to ops.pebble.Service so layer service equality can be checked (#592) Send a list of services to stop to pebble in restart() instead (#591) Make Container.restart() semantics operate more like system services (#588) Various documentation and testing harness improvements. Streamlined build, test and release process.
Bugfixes:
Adjust the ops.model.Resources.fetch method to throw a NameError (#661) Fix storage events with multiple hyphens #663 Exec test fixes and “for line in process.stdout” fix (#655) Fixed issue with float to decimal conversion causing trouble with metrics. #609 Fixed exception with very large log messages by splitting them #632 Fix Pebble push() handling of binary files #574 Fix Container.restart() accidentally operating on strings, add a testcase #590 Various testing harness bugfixes.
Full Changelog: https://github.com/canonical/operator/compare/1.2.0...1.3.0
- Python
Published by pengale about 4 years ago
ops - ops 1.2.0
A new release of the Charmed Operator Framework.
This release adds support for new ways of writing operators for kubernetes. Having your operator in a sidecar of the workload provides much more control over how the workload is running and configured. This adds attributes like Charm.unit.containers to interact with the other containers that are part of your pod. There is also updated testing infrastructure for ensuring that your charm is instantiating services in the shared containers correctly.
See our updated documentation (https://juju.is/docs/sdk/constructs) for how the new structure works.
This also includes fixes for: - #475 (lp:1914415) Ensure the Relation.app attribute is set correctly - #507 Network-get can return empty addresses
- Python
Published by jameinel almost 5 years ago
ops -
- Don't skip interfaces without names: they don't have names on k8s
- Python
Published by chipaca over 5 years ago
ops -
We added quite a few docstrings, and a test that will fail if something is missing docstrings.
We're more tolerant of missing fields in the output of
network-get, which can happen in some situations. Thanks to @johnsca for this one.Charm authors can run
self.configfrom a charm method instead of having to doself.model.config. Thanks to @johnsca for this one.Some ways of installing
opscan result in not loading thelibyamlextensions from PyYAML, giving a performance penalty.opswill warn when this happens so it can be remedied, but it would also warn when running the test suite which raises the barrier for developers wanting to contribute toopsitself. So now we ignore that. Thanks to @johnsca for this one.The
hooks_disabledcontext manager can now be nested. Thanks to @stub42 for this one.When using Juju for storage (either automatically by running on kubernetes with a new enough Juju, or manually via passing
use_juju_for_storage=Trueto main), events defered would never be re-emitted. This is #438, found with help from @davigar15.ObjectEvents now have a
__repr__which lists all events it knows about, which can be helpful when debugging (or even developing) a complex charm.sys.breakpointhookis only set frommain, not fromFramework.__init__, meaning it won't interfere with using thebreakpoint()builtin from tests.tests will now fail if a docstring is missing (or malformed).
- Python
Published by chipaca over 5 years ago
ops - This is version 0.10.0 of `ops`, the Operator Framework for Juju charms.
Changes include:
deleting a non-existent key from relation data will no longer fail. Thanks to @stub42 for the fix.
calling
begin_with_initial_hooks()on the testing harness of a charm that has a relation that isn't set up before the call will no longer fail. Thanks to @zzehring for the fix.the testing harness now starts with default config values, specified in the same way as for
actions.yamlandmetadata.yaml(i.e. snippets if given, otherwise from the canonical yaml file). Thanks to @johnsca for the work.some classes now have custom
__repr__methods that should aid debugging.event deferral and reëmission is now logged (at DEBUG).
if
use_juju_for_storageis specified for a charm running in a Juju that does not support this feature, a clear and explicit error is raised.the public attributes of
modelare now immutable. This is to discourage people from overwriting these attributes in tests, given there is a fair amount of internal state. Please use the harness instead (or mocking if you must).the test suite now passes on Windows, and we run the full suite on Windows for every commit, as we do for linux and macos.
- Python
Published by chipaca over 5 years ago
ops -
Release highlights:
Controller-side storage is now used automatically (i.e. without the charm author needing to set the
use_juju_for_storageflag onmain) when we're sure it's needed. It can still be forced on or off via that flag to main.A workaround for Juju's lp:1880637 to address #293, so
pod.set_spec'sk8s_resourcesworks as expected. But note #387, as "as expected" might not be as you expect.If charm code is run in an environment that does not set JUJU_VERSION, default to 0.0.0 instead of raising an exception. This means all the feature checks will fail, but the charm can still progress. Please let us know if this is not what you want; this impacts #372.
Charm authors can now use
harness.hooks_disabled()as a context manager to run a block of code without events being fired for them. Without this you'd have to wrap that code indisable/enablepairs.
- Python
Published by chipaca over 5 years ago
ops -
Changes include:
* testing Harness updates
Harness.begin_with_initial_hooks()will cause the testingHarnessto emit all of the events that Juju normally does while a charm is 'starting'. (install,leader-elected, etc.). While most unit tests should be more focused on a single hook interaction, this gives a bit more confidence that the whole initialization step of the charm operates in a good manner.Harness.get_pod_spec()allows a test to introspect what pod spec was set in response to their update event. Eg.,harness = Harness(MyCharm) # ... initial setup harness.begin() harness.update_config({'foo': 'bar'}) pod_spec, k8s_resources = harness.get_pod_spec() self.assertIsNone(k8s_resources) self.assertEqual(pod_spec['blah']['blah'], 'bar')Harness.cleanup()is now available to ensure that any temporary files/directories created by the harness are cleaned up. For unittest you would use this as:harness = Harness(MyCharm) self.addCleanup(harness.cleanup) ...This is currently only relevant if you are running tests that make use of resources (either
add_oci_resourceoradd_resource). However, it is good practice to start making use of it, in case there are other resources associated withHarnessthat will need to be cleaned up.Harness.add_resource()is now also available so that you can feed your charm code file content that it would get fromresource-get.- You no longer need to call
ops.lib.autoimportbefore your first call toops.lib.use; you only need to do it if the library information is out of date (e.g. if you installed or otherwise altered what the system would find). Also a lot more logging of the process of autodiscovery has been added. Thanks to @stub42 for pointing out how needing the first call was counter-intuitive, and the process hard to debug. - Libraries used via
ops.lib.usecan now have subpackages or modules. dispatch-aware charms that setJUJU_DISPATCH_PATHbefore calling into the framework caused the framework to think the Juju it was running on supported dispatch, even if the version was clearly too old for that. This meant that non-initial hooks were never called on these charms on those Jujus. Unfortunately charms created withcharmcraft0.3 fell into this category. The framework now looks directly at the Juju version to determine dispatch support. Thanks to @gnuoy for finding reporting this.
- You no longer need to call
- Python
Published by chipaca over 5 years ago
ops - 0.7.0
0.7.0 release highlights:
- opt-in to test controller-side state via Juju 2.8's state-get/state-set (#317, #323)
- support for running on Juju pre-2.7 (#324)
- exceptions now logged via an ad-hoc excepthook (#322)
- performance improvement for large yaml blobs (#325)
- bug fixes :-)
- Python
Published by chipaca over 5 years ago
ops - 0.6.0
This is the first “official” release, and includes a few breaking changes from what was in master until very recently. From now on, breaking changes will be announced, and we’ll have a deprecation procedure to ease things in (or rather, out). These breaking changes are:
- The
Frameworkobject’sobservemethod’s second argument can no longer be an instance, and must be a method on an instance. That is, where previously you could write
python
self.framework.observe(self.on.install, self)
as a shortcut, but we found that this pushes people down a path that actually makes their charms less maintainable. Especially when it comes to writing components, it is better to have clearly named functions and clearly defined targets.
So from now on the only supported way is to explicitly specify the callback method,
python
self.framework.observe(self.on.install, self._on_install)
(note we also recommend event handlers to be clearly marked as non-public).
- Relations'
roleattribute is now anenum, and in particular peer relation's role is now"peer"(it used to be"peers"which was just wrong).
This release includes full support for Juju 2.8's dispatch mechanism,including both use cases of dispatch being a symlink to the charm code, and dispatch being a small shim that executes the charm. The latter is an incremental improvement over what we mentioned in the last dev summary, and is already being used by charmcraft.
Lastly, Model objects now have a name property (populated from JUJU_MODEL_NAME). This was a feature requested by charmers.
- Python
Published by chipaca almost 6 years ago