Series Upgrade
Implement the series-upgrade feature allowing to move between Ubuntu series. Change-Id: Idcc77b66e65633eb26e485e93ef7928b7f455ca8
This commit is contained in:
parent
621ddb11b5
commit
ea6eb53059
|
@ -48,6 +48,13 @@ from charmhelpers.contrib.network.ip import (
|
||||||
get_relation_ip,
|
get_relation_ip,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
|
is_unit_paused_set,
|
||||||
|
set_unit_upgrading,
|
||||||
|
clear_unit_upgrading,
|
||||||
|
clear_unit_paused,
|
||||||
|
)
|
||||||
|
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
apt_install,
|
apt_install,
|
||||||
apt_purge,
|
apt_purge,
|
||||||
|
@ -83,6 +90,8 @@ from utils import (
|
||||||
needs_maas_dns_migration,
|
needs_maas_dns_migration,
|
||||||
write_maas_dns_address,
|
write_maas_dns_address,
|
||||||
MAASConfigIncomplete,
|
MAASConfigIncomplete,
|
||||||
|
pause_unit,
|
||||||
|
resume_unit,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.charmsupport import nrpe
|
from charmhelpers.contrib.charmsupport import nrpe
|
||||||
|
@ -133,6 +142,12 @@ def get_transport():
|
||||||
@hooks.hook('config-changed')
|
@hooks.hook('config-changed')
|
||||||
def config_changed():
|
def config_changed():
|
||||||
|
|
||||||
|
# if we are paused, delay doing any config changed hooks.
|
||||||
|
# It is forced on the resume.
|
||||||
|
if is_unit_paused_set():
|
||||||
|
log("Unit is pause or upgrading. Skipping config_changed", "WARN")
|
||||||
|
return
|
||||||
|
|
||||||
setup_ocf_files()
|
setup_ocf_files()
|
||||||
|
|
||||||
if config('prefer-ipv6'):
|
if config('prefer-ipv6'):
|
||||||
|
@ -481,6 +496,22 @@ def update_nrpe_config():
|
||||||
nrpe_setup.write()
|
nrpe_setup.write()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('pre-series-upgrade')
|
||||||
|
def series_upgrade_prepare():
|
||||||
|
set_unit_upgrading()
|
||||||
|
if not is_unit_paused_set():
|
||||||
|
pause_unit()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('post-series-upgrade')
|
||||||
|
def series_upgrade_complete():
|
||||||
|
log("Running complete series upgrade hook", "INFO")
|
||||||
|
clear_unit_paused()
|
||||||
|
clear_unit_upgrading()
|
||||||
|
config_changed()
|
||||||
|
resume_unit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
hooks.execute(sys.argv)
|
hooks.execute(sys.argv)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
hooks.py
|
|
@ -0,0 +1 @@
|
||||||
|
hooks.py
|
|
@ -0,0 +1 @@
|
||||||
|
hooks.py
|
|
@ -47,6 +47,7 @@ from charmhelpers.contrib.openstack.utils import (
|
||||||
set_unit_paused,
|
set_unit_paused,
|
||||||
clear_unit_paused,
|
clear_unit_paused,
|
||||||
is_unit_paused_set,
|
is_unit_paused_set,
|
||||||
|
is_unit_upgrading_set,
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.openstack.ha.utils import (
|
from charmhelpers.contrib.openstack.ha.utils import (
|
||||||
assert_charm_supports_dns_ha
|
assert_charm_supports_dns_ha
|
||||||
|
@ -849,7 +850,7 @@ def pause_unit():
|
||||||
status, message = assess_status_helper()
|
status, message = assess_status_helper()
|
||||||
if status != 'active':
|
if status != 'active':
|
||||||
messages.append(message)
|
messages.append(message)
|
||||||
if messages:
|
if messages and not is_unit_upgrading_set():
|
||||||
raise Exception("Couldn't pause: {}".format("; ".join(messages)))
|
raise Exception("Couldn't pause: {}".format("; ".join(messages)))
|
||||||
else:
|
else:
|
||||||
set_unit_paused()
|
set_unit_paused()
|
||||||
|
@ -863,6 +864,14 @@ def assess_status_helper():
|
||||||
@returns status, message - status is workload status and message is any
|
@returns status, message - status is workload status and message is any
|
||||||
corresponding messages
|
corresponding messages
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if is_unit_upgrading_set():
|
||||||
|
return ("blocked",
|
||||||
|
"Ready for do-release-upgrde. Set complete when finished")
|
||||||
|
if is_unit_paused_set():
|
||||||
|
return ("maintenance",
|
||||||
|
"Paused. Use 'resume' action to resume normal service.")
|
||||||
|
|
||||||
node_count = int(config('cluster_count'))
|
node_count = int(config('cluster_count'))
|
||||||
status = 'active'
|
status = 'active'
|
||||||
message = 'Unit is ready and clustered'
|
message = 'Unit is ready and clustered'
|
||||||
|
|
Loading…
Reference in New Issue