Add upgrade_if_available on config_changed

- reactive charms like aodh, barbican and etc uses the
  charms.openstack defaults for common states and hooks.
  The config-changed hook on the OpenStackCharm is missing a way
  of upgrading after changing the openstack-origin config, so the
  charm doesn't upgrade the packages.

- Without this, the charm can eventually upgrade if it needs to
  refresh the packages or if the user manually running the
  openstack-upgrade, but this is not an expected behavior.

Closes-Bug: #2039604
Change-Id: I35dd06c0cf2810599e2988536e22177e06ca2803
This commit is contained in:
Gabriel Cocenza 2024-04-29 17:40:11 -03:00
parent 760f1257ef
commit 966d70baa4
No known key found for this signature in database
2 changed files with 3 additions and 0 deletions

View File

@ -443,6 +443,7 @@ class OpenStackCharm(BaseOpenStackCharm,
def config_changed(self):
tls = reactive.endpoint_from_flag('certificates.available')
self.configure_tls(certificates_interface=tls)
self.upgrade_if_available(interfaces_list=None)
def configure_ssl(self, keystone_interface=None):
"""DEPRECATED Configure SSL certificates and keys.

View File

@ -476,8 +476,10 @@ class TestMyOpenStackCharm(BaseOpenStackCharmTest):
def test_config_changed(self):
self.patch_target('configure_tls')
self.patch_target('upgrade_if_available')
self.target.config_changed()
self.configure_tls.assert_called_once_with(certificates_interface=None)
self.upgrade_if_available.assert_called_once_with(interfaces_list=None)
self.configure_tls.reset_mock()
ep_mock = mock.MagicMock()