Add post-upgrade-configuration action

Add post-upgrade-configuration action which can be run after a Trilio
upgrade.

Trilio sometimes updates packages in package repositiories that
require DB migrations or config file changes. Since these package
updates are not applied by the charm as they would be by changing the
openstack-origin or triliovault-pkg-source the charm has no event to
react to to automatically perform the post package upgrade actions.
This change adds an action `post-upgrade-configuration` which can
be run to apply the changes.

func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/613
Change-Id: I4dcc5d285e705c15ffc72c4497c3154877c7a44f
This commit is contained in:
Liam Young 2021-08-03 13:16:30 +00:00
parent c7b1058820
commit 5e45300331
4 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ test-charm/
.stestr
.coverage
cover
*.swp

View File

@ -16,3 +16,8 @@ ghost-share:
description: Comma separated nfs-shares configuration option from secondary deployment. NFS shares must be provided in the same order as the nfs-shares configuration option for the local deployment.
required:
- nfs-shares
post-upgrade-configuration:
description: |
If the Trilio packages were upgraded outside of the charms control then run
this action to rerender configuration files and run any upgrade tasks such
as database migrations.

View File

@ -66,12 +66,23 @@ def ghost_share(*args):
trilio_wlm_charm._assess_status()
def post_upgrade_configuration(*args):
"""Run setup after Trilio upgrade.
"""
with charms_openstack.charm.provide_charm_instance() as trilio_wlm_charm:
trilio_wlm_charm.render_all_configs()
if hookenv.is_leader():
trilio_wlm_charm.do_trilio_upgrade_db_migration()
trilio_wlm_charm._assess_status()
# Actions to function mapping, to allow for illegal python action names that
# can map to a python function.
ACTIONS = {
"create-cloud-admin-trust": create_cloud_admin_trust,
"create-license": create_license,
"ghost-share": ghost_share,
"post-upgrade-configuration": post_upgrade_configuration,
}

View File

@ -0,0 +1 @@
actions.py