Ensure octavia-driver-agents gets installed

Due to a 'quirk' being fixed, the octavia-driver-agents don't get
installed if the ovsdb-subordinate  relation is the last to be made.
This is due to the update-status hook gating the reactive handler from
running which 'fixed' the issue.  Looking deeper, if the handler isn't
the first to run, then the charm's packages won't get initialised
properly.

This patch fixes that by using the dynamic properties 'all_packages' and
'full_service_list' available in charms.openstack core for the Charm
class.  This means that it doesn't matter when the flag is set, as long
as it is before the property is accessed.  Looking at the handler, this
will be in the right place for the install.

func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/514

Change-Id: I5fd75c9d371390bca402d6a3a264421a44fd092a
Closes-Bug: #1916764
This commit is contained in:
Alex Kavanagh 2021-03-01 13:33:18 +00:00
parent a27fa074c0
commit 22f4ae5d02
2 changed files with 15 additions and 7 deletions

View File

@ -474,14 +474,22 @@ class UssuriOctaviaCharm(BaseOctaviaCharm):
"""Charm class for the Octavia charm on Ussuri and newer releases."""
release = 'ussuri'
def __init__(self, **kwargs):
@property
def all_packages(self):
all_packages = super().all_packages
# NOTE(fnordahl): We probably should have a more generic harness for
# these kinds of extensions, there might be more SDNs that want support
# in the charm.
if reactive.is_flag_set('charm.octavia.enable-ovn-driver'):
self.packages.extend([
all_packages.extend([
'octavia-driver-agent',
'python3-ovn-octavia-provider'
])
self.services.extend(['octavia-driver-agent'])
super().__init__(**kwargs)
return all_packages
@property
def full_service_list(self):
services = super().full_service_list
if reactive.is_flag_set('charm.octavia.enable-ovn-driver'):
services.extend(['octavia-driver-agent'])
return services

View File

@ -134,9 +134,9 @@ class TestOctaviaCharm(Helper):
'python3-ovn-octavia-provider' in self.target.packages)
self.patch_object(octavia.reactive, 'is_flag_set', return_value=True)
c = octavia.UssuriOctaviaCharm()
self.assertTrue('octavia-driver-agent' in c.packages)
self.assertTrue('python3-ovn-octavia-provider' in c.packages)
self.assertTrue('octavia-driver-agent' in c.services)
self.assertTrue('octavia-driver-agent' in c.all_packages)
self.assertTrue('python3-ovn-octavia-provider' in c.all_packages)
self.assertTrue('octavia-driver-agent' in c.full_service_list)
def test_install(self):
# we do not care about the internals of the function we are overriding