Fix removal of designate-agent package in caracal
In the current implementation, the charm instance i.e., DesignateCharm<*> passes a release name based on python-keystonemiddleware package. However the internal logic ignores the package and installs openstack-release package and determines the release and creates singleton class for that release. The singelton class determines the list of packages etc. However at this point of time, the cloud-archive source is not yet updated. In case of jammy-caracal deployment, the openstack-release package is installed from jammy since the cloud archive source is not updated and hence openstack release is considered as yoga. This means packages listed in DesignateCharmYoga will be installed that includes designate-agent. After running some handlers, configure_designate_full crosschecks the packages with openstack-origin configuration and starts upgrading the packages to caracal. There are no purge_packages listed in CharmDesignateCaracal and so designate-agent is not removed during this upgrade. Do not pass any release so that charms.openstack library figures out the release name after updating the cloud-archive sources. This should fix issues for a greenfield deployment. For the case of upgrades from earlier releases where designate-agent is already installed, update purge packages in CharmDesignateCaracal. To remove/purge nrpe service check, add logic to trigger remove_deperecated_packages. There is a case where designate-agent gets purged and reinstalled due to the way hooks are triggered and singleton class is maintained. To overcome this, always remove_obselete_packages in configure_designate_full handler. Closes-Bug: #2111227 Change-Id: I9f8ce93b9751a65e8e181cf9aa7411a4047318bb
This commit is contained in:
@@ -315,6 +315,8 @@ class DesignateCharm(ch_plugins.PolicydOverridePlugin,
|
||||
'designate-central', 'designate-sink',
|
||||
'designate-api']
|
||||
|
||||
deprecated_services = []
|
||||
|
||||
api_ports = {
|
||||
'designate-api': {
|
||||
os_ip.PUBLIC: 9001,
|
||||
@@ -370,15 +372,6 @@ class DesignateCharm(ch_plugins.PolicydOverridePlugin,
|
||||
# policyd override constants
|
||||
policyd_service_name = 'designate'
|
||||
|
||||
def __init__(self, release=None, **kwargs):
|
||||
"""Custom initialiser for class
|
||||
If no release is passed, then the charm determines the release from the
|
||||
ch_utils.os_release() function.
|
||||
"""
|
||||
if release is None:
|
||||
release = ch_utils.os_release('python-keystonemiddleware')
|
||||
super(DesignateCharm, self).__init__(release=release, **kwargs)
|
||||
|
||||
def install(self):
|
||||
"""Customise the installation, configure the source and then call the
|
||||
parent install() method to install the packages
|
||||
@@ -657,6 +650,8 @@ class DesignateCharm(ch_plugins.PolicydOverridePlugin,
|
||||
nrpe.add_init_service_checks(
|
||||
charm_nrpe, self.services, current_unit)
|
||||
charm_nrpe.write()
|
||||
# Remove service checks for which services are no longer needed
|
||||
nrpe.remove_deprecated_check(charm_nrpe, self.deprecated_services)
|
||||
|
||||
def add_nrpe_nameserver_checks(self):
|
||||
"""Add NRPE service checks for upstream nameservers."""
|
||||
@@ -804,7 +799,17 @@ class DesignateCharmCaracal(DesignateCharmRocky):
|
||||
'python3-designate',
|
||||
'python3-apt']
|
||||
|
||||
purge_packages = [
|
||||
'python-designate',
|
||||
'python-memcache',
|
||||
'designate-agent',
|
||||
'designate-zone-manager',
|
||||
'designate-pool-manager',
|
||||
]
|
||||
|
||||
services = ['designate-mdns', 'designate-producer',
|
||||
'designate-worker',
|
||||
'designate-central', 'designate-sink',
|
||||
'designate-api']
|
||||
|
||||
deprecated_services = ["designate-agent"]
|
||||
|
@@ -210,6 +210,19 @@ def configure_designate_full(*args):
|
||||
args = args + (dns_backend, )
|
||||
with charm.provide_charm_instance() as instance:
|
||||
instance.upgrade_if_available(args)
|
||||
# Workaround to purge packages in case of upgrades from one release to
|
||||
# another
|
||||
# Eventhough upgrade_if_available() purges the unnecessary packages,
|
||||
# reactive/layer_openstack.py::default_upgrade_charm again tries to
|
||||
# install due to singleton class pointing to older release charm
|
||||
# instance i.e., it installs all the packages mentioned in older
|
||||
# release. After that even though configure_designate_full() is
|
||||
# triggered, upgrade_if_available does nothing as the installed
|
||||
# packages are already of same release as expected and it
|
||||
# did not care about purge packages.
|
||||
# Example scenario that triggered this change is removal of
|
||||
# designate-agent from caracal release
|
||||
instance.remove_obsolete_packages()
|
||||
instance.configure_ssl()
|
||||
instance.render_full_config(args)
|
||||
try:
|
||||
|
@@ -221,6 +221,7 @@ class TestHandlers(test_utils.PatchHelper):
|
||||
the_charm.update_pools.assert_called_once_with()
|
||||
the_charm.upgrade_if_available.assert_called_once_with(
|
||||
('arg1', 'arg2', ))
|
||||
the_charm.remove_obsolete_packages.assert_called_once_with()
|
||||
|
||||
def test_cluster_connected(self):
|
||||
the_charm = self._patch_provide_charm_instance()
|
||||
|
Reference in New Issue
Block a user