Improve messaging for required relations
At present the `certificates` relation will report as missing until Vault is equipped with a root CA to issue certificates. Change-Id: I1e0333c0910cb2cfd1c412f21b1f5bd6db3b35e3
This commit is contained in:
parent
a8d855277d
commit
124f13ac26
@ -18,6 +18,7 @@ import charms_openstack.adapters
|
|||||||
import charms_openstack.charm
|
import charms_openstack.charm
|
||||||
|
|
||||||
|
|
||||||
|
CERT_RELATION = 'certificates'
|
||||||
NEUTRON_PLUGIN_ML2_DIR = '/etc/neutron/plugins/ml2'
|
NEUTRON_PLUGIN_ML2_DIR = '/etc/neutron/plugins/ml2'
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ def ovn_ca_cert(cls):
|
|||||||
class BaseNeutronAPIPluginCharm(charms_openstack.charm.OpenStackCharm):
|
class BaseNeutronAPIPluginCharm(charms_openstack.charm.OpenStackCharm):
|
||||||
abstract_class = True
|
abstract_class = True
|
||||||
name = 'neutron-api-plugin-ovn'
|
name = 'neutron-api-plugin-ovn'
|
||||||
required_relations = ['neutron-plugin', 'ovsdb-cms']
|
required_relations = [CERT_RELATION, 'neutron-plugin', 'ovsdb-cms']
|
||||||
python_version = 3
|
python_version = 3
|
||||||
release_pkg = version_package = 'neutron-common'
|
release_pkg = version_package = 'neutron-common'
|
||||||
# make sure we can write secrets readable by the ``neutron-server`` process
|
# make sure we can write secrets readable by the ``neutron-server`` process
|
||||||
@ -120,6 +121,42 @@ class BaseNeutronAPIPluginCharm(charms_openstack.charm.OpenStackCharm):
|
|||||||
tls_object['key'],
|
tls_object['key'],
|
||||||
cn='host')
|
cn='host')
|
||||||
|
|
||||||
|
def states_to_check(self, required_relations=None):
|
||||||
|
"""Override parent method to add custom messaging.
|
||||||
|
|
||||||
|
Note that this method will only override the messaging for certain
|
||||||
|
relations, any relations we don't know about will get the default
|
||||||
|
treatment from the parent method.
|
||||||
|
|
||||||
|
:param required_relations: Override `required_relations` class instance
|
||||||
|
variable.
|
||||||
|
:type required_relations: Optional[List[str]]
|
||||||
|
:returns: Map of relation name to flags to check presence of
|
||||||
|
accompanied by status and message.
|
||||||
|
:rtype: collections.OrderedDict[str, List[Tuple[str, str, str]]]
|
||||||
|
"""
|
||||||
|
# Retrieve default state map
|
||||||
|
states_to_check = super().states_to_check(
|
||||||
|
required_relations=required_relations)
|
||||||
|
|
||||||
|
# The parent method will always return a OrderedDict
|
||||||
|
if CERT_RELATION in states_to_check:
|
||||||
|
# for the certificates relation we want to replace all messaging
|
||||||
|
states_to_check[CERT_RELATION] = [
|
||||||
|
# the certificates relation has no connected state
|
||||||
|
('{}.available'.format(CERT_RELATION),
|
||||||
|
'blocked',
|
||||||
|
"'{}' missing".format(CERT_RELATION)),
|
||||||
|
# we cannot proceed until Vault have provided server
|
||||||
|
# certificates
|
||||||
|
('{}.server.certs.available'.format(CERT_RELATION),
|
||||||
|
'waiting',
|
||||||
|
"'{}' awaiting server certificate data"
|
||||||
|
.format(CERT_RELATION)),
|
||||||
|
]
|
||||||
|
|
||||||
|
return states_to_check
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def db_migration_needed(self):
|
def db_migration_needed(self):
|
||||||
"""Determine whether DB migration is needed.
|
"""Determine whether DB migration is needed.
|
||||||
|
@ -8,13 +8,13 @@ gate_bundles:
|
|||||||
target_deploy_status:
|
target_deploy_status:
|
||||||
neutron-api-plugin-ovn:
|
neutron-api-plugin-ovn:
|
||||||
workload-status: waiting
|
workload-status: waiting
|
||||||
workload-status-message: "'ovsdb-cms' incomplete"
|
workload-status-message: "'certificates' awaiting server certificate data, 'ovsdb-cms' incomplete"
|
||||||
ovn-central:
|
ovn-central:
|
||||||
workload-status: blocked
|
workload-status: waiting
|
||||||
workload-status-message: "'certificates' missing"
|
workload-status-message: "'ovsdb-peer' incomplete, 'certificates' awaiting server certificate data"
|
||||||
ovn-chassis:
|
ovn-chassis:
|
||||||
workload-status: blocked
|
workload-status: waiting
|
||||||
workload-status-message: "'certificates' missing"
|
workload-status-message: "'certificates' awaiting server certificate data"
|
||||||
vault:
|
vault:
|
||||||
workload-status: blocked
|
workload-status: blocked
|
||||||
workload-status-message: Vault needs to be initialized
|
workload-status-message: Vault needs to be initialized
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import collections
|
||||||
import io
|
import io
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
|
import unittest.mock as mock
|
||||||
|
|
||||||
import charms_openstack.test_utils as test_utils
|
import charms_openstack.test_utils as test_utils
|
||||||
|
|
||||||
@ -88,6 +89,30 @@ class TestNeutronAPIPluginOvnCharm(Helper):
|
|||||||
cn='host',
|
cn='host',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_states_to_check(self):
|
||||||
|
self.maxDiff = None
|
||||||
|
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
|
||||||
|
expect = collections.OrderedDict([
|
||||||
|
('certificates', [
|
||||||
|
('certificates.available', 'blocked',
|
||||||
|
"'certificates' missing"),
|
||||||
|
('certificates.server.certs.available',
|
||||||
|
'waiting',
|
||||||
|
"'certificates' awaiting server certificate data")]),
|
||||||
|
('neutron-plugin', [
|
||||||
|
('neutron-plugin.connected',
|
||||||
|
'blocked',
|
||||||
|
"'neutron-plugin' missing"),
|
||||||
|
('neutron-plugin.available',
|
||||||
|
'waiting',
|
||||||
|
"'neutron-plugin' incomplete")]),
|
||||||
|
('ovsdb-cms', [
|
||||||
|
('ovsdb-cms.connected', 'blocked', "'ovsdb-cms' missing"),
|
||||||
|
('ovsdb-cms.available', 'waiting', "'ovsdb-cms' incomplete")]),
|
||||||
|
|
||||||
|
])
|
||||||
|
self.assertDictEqual(c.states_to_check(), expect)
|
||||||
|
|
||||||
def test_service_plugins(self):
|
def test_service_plugins(self):
|
||||||
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
|
c = neutron_api_plugin_ovn.UssuriNeutronAPIPluginCharm()
|
||||||
svc_plugins = (
|
svc_plugins = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user