Skip to content

Add bits to release zaza as a python package#696

Merged
dosaboy merged 5 commits into
openstack-charmers:masterfrom
freyes:release-process
May 7, 2026
Merged

Add bits to release zaza as a python package#696
dosaboy merged 5 commits into
openstack-charmers:masterfrom
freyes:release-process

Conversation

@freyes

@freyes freyes commented May 5, 2026

Copy link
Copy Markdown
Member

This pull request introduces the necessary infrastructure to release zaza as a proper Python package on PyPI, enabling consumers to pin version ranges (e.g., zaza<2024.2.0) for better dependency management across OpenStack charm releases.

Key changes included:

  • setuptools-scm integration — the package version is now derived automatically from Git tags, removing the need for manual version bumping.
  • tox environments for build and upload — tox -e build and tox -e upload streamline the release workflow.
  • Replaced ntp with local-users charm in testing bundles — ntp/chrony fails in containerised environments (where system clock control is disabled), making it inappropriate for our CI setup.
  • Retry logic for model reconnection — uses tenacity to retry reconnecting to a model, improving resilience in flaky environments.
  • Controller model log capture — logs from the controller model are now captured for better observability during test runs.
  • Disabled upterm in CI workflow.

Motivation:

As the OpenStack charm ecosystem matures, consumers need a reliable way to pin zaza to specific release series (e.g., Caracal). Publishing versioned packages to PyPI makes this straightforward and aligns zaza with standard Python packaging practices.

Please review and let me know if any adjustments are needed. CI is green (modulo the pre-existing ntp container issue, which this PR also fixes).

freyes added 2 commits May 5, 2026 14:27
The version of the python package is picked up automatically using
setuptools-scm

Usage:

  tox -e build
  tox -e upload

The intention is to start releasing python packages of zaza through
Pypi to enable consumers to pin ranges of zaza, e.g. `zaza<2024.2.0` to
pull in any caracal compatible version of zaza.

Signed-off-by: Felipe Reyes <felipe.reyes@canonical.com>
Signed-off-by: Felipe Reyes <felipe.reyes@canonical.com>
@freyes

freyes commented May 5, 2026

Copy link
Copy Markdown
Member Author

ntp is failing when trying to restart chrony

2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60 installing ntpmon
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60 Traceback (most recent call last):
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/charm/hooks/install", line 22, in <module>
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     main()
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/.venv/lib/python3.8/site-packages/charms/reactive/__init__.py", line 74, in main
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     bus.dispatch(restricted=restricted_mode)
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 390, in dispatch
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     _invoke(other_handlers)
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 359, in _invoke
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     handler.invoke()
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 181, in invoke
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     self._action(*args)
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/charm/reactive/ntp.py", line 148, in install
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     update_chrony_umask()
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/var/lib/juju/agents/unit-ntp-0/charm/reactive/ntp.py", line 113, in update_chrony_umask
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     subprocess.check_call(['systemctl', 'restart', 'chrony'])
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60   File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60     raise CalledProcessError(retcode, cmd)
2026-05-05 18:51:02 WARNING unit.ntp/0.install logger.go:60 subprocess.CalledProcessError: Command '['systemctl', 'restart', 'chrony']' returned non-zero exit status 1.
...
ubuntu/2*        active       idle       6        10.223.22.204          
  ntp/0*         error        idle                10.223.22.204          hook failed: "install"
...
6        started  10.223.22.204  juju-70c90f-6  focal       Running

@freyes

freyes commented May 5, 2026

Copy link
Copy Markdown
Member Author

I'm going to drop ntp from the testing bundles. It doesn't make sense to have it when running in a container, and we don't have the resources to switch to using VMs.


May  5 18:51:01 juju-70c90f-6 systemd[1]: Starting chrony, an NTP client/server...
May  5 18:51:02 juju-70c90f-6 chronyd-starter.sh[9624]: WARNING: libcap needs an update (cap=40 should have a name).
May  5 18:51:02 juju-70c90f-6 chronyd-starter.sh[9622]: Warning: Running in a container, likely impossible and unintended to sync system clock
May  5 18:51:02 juju-70c90f-6 chronyd-starter.sh[9622]: Adding -x as fallback disabling control of the system clock, see /usr/share/doc/chrony/README.container to override this behavior
May  5 18:51:02 juju-70c90f-6 chronyd[9627]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 -DEBUG)
May  5 18:51:02 juju-70c90f-6 chronyd[9627]: Disabled control of system clock
May  5 18:51:02 juju-70c90f-6 chronyd-starter.sh[9625]: Could not open any command socket
May  5 18:51:02 juju-70c90f-6 chronyd[9627]: Could not open IPv4 command socket : Permission denied
May  5 18:51:02 juju-70c90f-6 chronyd[9627]: Could not open IPv6 command socket : Permission denied
May  5 18:51:02 juju-70c90f-6 chronyd[9627]: Fatal error : Could not open any command socket
May  5 18:51:02 juju-70c90f-6 systemd[1]: chrony.service: Control process exited, code=exited, status=1/FAILURE
May  5 18:51:02 juju-70c90f-6 systemd[1]: chrony.service: Failed with result 'exit-code'.
May  5 18:51:02 juju-70c90f-6 systemd[1]: Failed to start chrony, an NTP client/server.

@freyes freyes force-pushed the release-process branch 5 times, most recently from 63e2ea1 to 7b4c170 Compare May 6, 2026 14:57
This will exercise the use of subordinate charms without having to deal
with github runner issues when running chronny

Signed-off-by: Felipe Reyes <felipe.reyes@canonical.com>
@freyes freyes force-pushed the release-process branch from 7b4c170 to e084b48 Compare May 6, 2026 14:59
Wrap model.connect_model() in a tenacity.AsyncRetrying loop with up to
5 attempts and a 5-second wait between retries. On exhaustion a
ModelTimeout exception is raised instead of silently failing.

Fixes scenarios where the connection to the controller is unstable, like
resource constrained environments

    websockets.exceptions.InvalidMessage: did not receive a valid HTTP response

Unit tests added to cover:
- Successful reconnect on first attempt
- Transient failures with eventual success
- ModelTimeout raised after all retries exhausted
- No reconnect attempted when model is already connected

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Felipe Reyes <felipe.reyes@canonical.com>
@freyes freyes force-pushed the release-process branch from c281965 to 6a57fd6 Compare May 6, 2026 18:12
Signed-off-by: Felipe Reyes <felipe.reyes@canonical.com>
@freyes freyes marked this pull request as ready for review May 6, 2026 20:55
@freyes freyes requested a review from dosaboy May 6, 2026 20:58
@freyes

freyes commented May 6, 2026

Copy link
Copy Markdown
Member Author
$ tox -e build
...
copying zaza.egg-info/SOURCES.txt -> zaza-2024.1.1.dev5+g45e5b28cb.d20260506/zaza.egg-info
Writing zaza-2024.1.1.dev5+g45e5b28cb.d20260506/setup.cfg
Creating tar archive
removing 'zaza-2024.1.1.dev5+g45e5b28cb.d20260506' (and everything under it)
Successfully built zaza-2024.1.1.dev5+g45e5b28cb.d20260506.tar.gz
  build: OK (20.81=setup[18.88]+cmd[1.93] seconds)
  congratulations :) (20.95 seconds)
$ ls dist/
zaza-2024.1.1.dev5+g45e5b28cb.d20260506.tar.gz  zaza-2024.1.2.tar.gz
$ git describe --tag 
v2024.1.0-5-g45e5b28

@dosaboy dosaboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think looks good. we'll know if the workflows work for sure when it lands...

@dosaboy dosaboy merged commit b46b0d5 into openstack-charmers:master May 7, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants