Juju-doctor is a pypi package which helps validate Juju deployments using probes.
Project description
🩺 juju-doctor 🩺
Run a configurable set of probes (assertions) against Juju deployment artifacts, which are the output of other tools like juju, sosreport, and kubectl. To enforce best practices, these probes are organized into a ruleset, which acts as a guide for correct deployment configurations.
Usage
Here's some typical usage examples:
∮ juju-doctor check --help # displays the help
You can run juju-doctor against a solution archive:
∮ juju-doctor check \
--probe file://tests/resources/probes/python/failing.py \
--probe file://tests/resources/probes/python/passing.py \
--status=status.yaml \
--status=status.yaml
If you have a live deplyoment, you can also run juju-doctor against that:
∮ juju-doctor check \
--probe file://tests/resources/probes/python/failing.py \
--probe file://tests/resources/probes/python/passing.py \
--model testy \
--model testy-two
In either case, the output will look like so (configurable with --format and --verbose):
Results
├── fail
│ └── 🔴 tests_resources_probes_python_failing.py (bundle, show_unit, status)
└── pass
└── 🟢 tests_resources_probes_python_passing.py
Total: 🟢 3 🔴 3
The path to a probe can also be a url:
# Run a remote probe against a live model
∮ juju-doctor check --model cos --probe github://canonical/grafana-k8s-operator//probes/some_probe.py
Writing Probes
Scriptlet
Scriptlet probes are written in Python, and can run on standardized artifacts that can be provided either as static files, or gathered from a live model.
Currently, we support the following artifacts:
status:juju status --format=yamlbundle:juju export-bundleshow_unit:juju show-unit --format=yaml
To write a probe, you should start by choosing an artifact. Your code will only have access to one artifact type at a time, but the input information can span multiple models.
Then, write a function named after your artifact (e.g., status, bundle, etc.) that takes one Dict argument: the artifact of choice indexed by model name. The function should raise an exception if you want your probe to fail, explaining why it failed.
Let's look at an example.
from typing import Dict
def status(juju_statuses: Dict[str, Dict]): # {'cos': juju_status_dict, ...}
... # do things with the Juju statuses
if not all_good:
raise Exception("'coconut' charm shouldn't be there!")
def bundle(juju_bundles: Dict[str, Dict]):
... # do things with the Juju bundles
if not passing:
raise Exception("who deployed the 'coconut' charm?")
def _first_check(...):
...
def _second_check(...):
...
# You can split multiple checks in functions
def show_unit(juju_show_units):
...
_first_check()
_second_check()
Remember: juju-doctor will only run functions that exactly match a supported artifact name, and will always pass to them a dictionary of model name mapped to the proper artifact.
Ruleset
Ruleset probes are written in YAML, specifying which probes should be coordinated for a deployment validation.
Currently, we support the following probe types:
scriptlet: A Python proberuleset: A declarative deployment RuleSetdirectory: A directory of probes (from the types in this list)
name: A declarative deployment RuleSet
probes:
- name: Local probe - passing
type: scriptlet
url: file://tests/resources/probes/python/passing.py
- name: Local ruleset
type: ruleset
url: file://tests/resources/probes/ruleset/ruleset.yaml
- name: Local probe directory (may contain scriptlets and/or rulesets)
type: directory
url: file://tests/resources/probes/ruleset/small-dir
Development
git clone https://github.com/canonical/juju-doctor.git
uv sync --extra=dev && source .venv/bin/activate
uv pip install -e .
juju-doctor check --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file juju_doctor-0.1.7.tar.gz.
File metadata
- Download URL: juju_doctor-0.1.7.tar.gz
- Upload date:
- Size: 186.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eff1a28ee7db2f65443dfd85656409540f98d07fa04846df152cb70fad99b4cc
|
|
| MD5 |
397ed23d4645e09d1657d1f1f5ea578a
|
|
| BLAKE2b-256 |
9b0c47f5f68fb2318e5ac910177cb1e3fca7617af9a146bdecad9ac4a907d64d
|
Provenance
The following attestation bundles were made for juju_doctor-0.1.7.tar.gz:
Publisher:
release.yaml on canonical/juju-doctor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
juju_doctor-0.1.7.tar.gz -
Subject digest:
eff1a28ee7db2f65443dfd85656409540f98d07fa04846df152cb70fad99b4cc - Sigstore transparency entry: 219198399
- Sigstore integration time:
-
Permalink:
canonical/juju-doctor@f8c73340049b53b25a3fe68b16a310f33f5d02d7 -
Branch / Tag:
refs/tags/0.1.7 - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@f8c73340049b53b25a3fe68b16a310f33f5d02d7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file juju_doctor-0.1.7-py3-none-any.whl.
File metadata
- Download URL: juju_doctor-0.1.7-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a53b9cc4348141cacabafdf548d58dd08fbc42adda36cdfe9ce0998ea4414a8d
|
|
| MD5 |
70443bbc66ef979c6226a78163f9ffcc
|
|
| BLAKE2b-256 |
1256bad07d5fb35dd3bbed6c24ebd85a8d3465926773babc0fd348e68342c2dc
|
Provenance
The following attestation bundles were made for juju_doctor-0.1.7-py3-none-any.whl:
Publisher:
release.yaml on canonical/juju-doctor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
juju_doctor-0.1.7-py3-none-any.whl -
Subject digest:
a53b9cc4348141cacabafdf548d58dd08fbc42adda36cdfe9ce0998ea4414a8d - Sigstore transparency entry: 219198400
- Sigstore integration time:
-
Permalink:
canonical/juju-doctor@f8c73340049b53b25a3fe68b16a310f33f5d02d7 -
Branch / Tag:
refs/tags/0.1.7 - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@f8c73340049b53b25a3fe68b16a310f33f5d02d7 -
Trigger Event:
release
-
Statement type: