Package: juju-verify
Juju verifyThis CLI tool is a Juju plugin that allows user to check whether it's safe
to perform some disruptive maintenance operations on Juju units, likeshutdownorreboot.RequirementsJuju-verify requires Juju 2.8.10 or higher.Supported charmsnova-computeceph-osdceph-monneutron-gatewayovn-centralSupported checksrebootshutdownContribution and lifecycleFor more information on how to contribute and the lifecycle ofjuju-verifytools,
visitCONTRIBUTINGpage.Usage exampleTo verify that it is safe to stop/shutdown unitsnova-compute/0andnova-compute/1without affecting the rest of the OpenStack cloud environment,
run the following.$juju-verifyshutdown--unitsnova-compute/0nova-compute/1
$jujuverifyshutdown-unova-compute/nova-compute/1To verify that it is safe to reboot all principal units from a Juju machine, run the following.$juju-verifyreboot--machines6$jujuverifyreboot-M6For more information, visit thejuju-verify-getting-startedpage.Known limitationsargparse limitation withnargs="+"type of arguments. The core Juju client allows
commands after options (e.g.juju --run unit/0 ls).juju-verifyneeds to pass the
type of check (reboot,shutdown) at the beginning of the command, otherwise it will
be parsed as a unit (or machine).juju-verify -u unit/0 rebootwill fail.juju-verify reboot -u unit/0will succeed.If you run a check on a unit which contains a subordinate unit, you will only get
a warning message about the existence of the subordinate unit. In order to check if
it is safe to reboot/shutdown this unit, juju-verify needs to be explicitly run
against this subordinate unit, or the unit needs to be manually checked (if
juju-verify does not support this charm yet)Example:$juju-verifyshutdown--unitsceph-osd/0===[ceph-osd/0]===Checks:[WARN]ceph-osd/0hasunitsrunningonchildmachines:ceph-mon/0*[OK]ceph-mon/0:Cephclusterishealthy[OK]Minimumreplicanumbercheckpassed.[OK]Availabilityzonecheckpassed.

Result:OK(Checkspassedwithwarnings)How to contributeIs your favorite charm missing from the list of supported charm? Don't hesitate
to add it. This plugin is easily extensible.All you need to do is create new class injuju_verify.verifierspackage that
inherits fromjuju_verify.verifiers.BaseVerifier(see the class documentation for
more details) and implement the necessary logic.Then, the charm name needs to be added toSUPPORTED_CHARMSdictionary injuju_verify/verifiers/__init__.pyet voilà, the charm is now supported.TestingDon't forget to add unit and functional tests.UnittestsUnit tests can be executed in these ways:makeunittest# ortox-eunitHowever, it is recommended to run unit tests at the same time as lint tests as follows:maketests# ortoxFunctional testsFunctional tests can be run using:makefunctional# ortox-efuncFunctional tests require some applications to use a VIP. Please ensure theOS_VIP00environment variable is set to a suitable VIP address before running functional tests.During development, different variations of all the functional tests may be run.
Find some examples below:tox -e funcruns all bundles and does not keep any Juju modeltox -e func -- --keep-faulty-modelruns all bundles and keeps the Juju models that
failedtox -e func -- --keep-all-models --log DEBUGruns all bundles w/ logging in debug
mode and keeping all the Juju modelstox -e func-target -- cephruns only the Ceph bundle and not keep the Juju modeltox -e func-target -- ceph --keep-model --log DEBUGruns only the Ceph bundle w/
logging in debug mode and keep
the Juju modelCode decisionsThe main idea ofjuju-verifyis to be used as a CLI tool with an entry point defined
injuju verify/juju verify.py. We use theargparselibrary to parse CLI arguments
and to provide help information, which can be accessed usingjuju-verify --helpcommand.Despite the main purpose, it is possible to usejuju-verifyas python package. It
can be installed directly frompypi.org.VerifiersThe basic structure of the verifier is defined in the/juju_verify/verifiers/base.pyfile as theBaseVerifierclass. Every other verifier must inherit from this class,
with the following variable and functions having to be overrided.NAME- name of verifierverify_<action-with-unit>- function to run all necessary checks when trying to
perform "action" with the unitEach verifier will contain these two variables:units - list of units we want to verifymodel - corresponding model containing unitsThe verifier should run a verification using theverifyfunction, which will check
if the verification is supported and adds these pre-checks:check_affected_machines - Check if affected machines run other principal units.check_has_sub_machines - Check if the machine hosts containers or VMs.For more information about the verifier, seejuju-verify-verifierspage.NOTE: There is a list of supported verifiers that corresponded to the list ofsupported charms.ChecksThe recommended way is to divide a unit check into several smaller checks with
self-explanatory names and a good docstring. Than all sub-checks should be run withchecks_executor, which aggregates the results from each check or provide default
result. It also catches any of the following errorsJujuActionFailed,CharmException,KeyErrororJSONDecodeError, giving a FAIL result with a message
in the form "{check.name} check failed with error: {error}".ResultsAResultis a class object that represents the output of any check that can be
aggregated together with other results. Each result consists of one or more sub-results
represented as aPartialclass, the partial result consists of severity and meesage.There are currently 4 severity tips:OK - representing a successful checkWARN - the result ended successfully, but there was a possibility that may have
an unexpected impact on the resultUNSUPPORTED - result of check is not supportedFAIL - check failedThe final result is successful if no partial result ends other than with the OK or
WARN severity. The string representation of results is an aggregation of partial
results, which are represented as severiny name and message.In the following example, we can see four checks, one ending with a severity WARN
and three ending with a severity OK, but the overall result is OK.$juju-verifyshutdown--unitceph-osd/0===[ceph-osd/0]===Checks:[WARN]ceph-osd/0hasunitsrunningonchildmachines:ceph-mon/0*[OK]ceph-mon/0:Cephclusterishealthy[OK]Minimumreplicanumbercheckpassed.[OK]Availabilityzonecheckpassed.

Result:OK(Checkspassedwithwarnings)Submit a bugIf you prefer, file a bug or feature request at:https://bugs.launchpad.net/juju-verify