Ensure get_requests_for_local_unit doesn't fail on incomplete relation
This is a rebuild/make sync for charms to pickup the fix in charmhelpers to fix any inadvertant accesses of ['ca'] in the relation data before it is available from vault in the certificates relation. Fix in charmhelpers is in [1]. [1] https://github.com/juju/charm-helpers/pull/824 Closes-Bug: #2028683 Change-Id: Ifb8dd875065af94e6aa1b2433638ea52b410b72f
This commit is contained in:
parent
636c9e3598
commit
912d2bed51
|
@ -414,18 +414,27 @@ def get_requests_for_local_unit(relation_name=None):
|
||||||
is_legacy_request = set(sent).intersection(legacy_keys)
|
is_legacy_request = set(sent).intersection(legacy_keys)
|
||||||
for unit in related_units(rid):
|
for unit in related_units(rid):
|
||||||
data = relation_get(rid=rid, unit=unit)
|
data = relation_get(rid=rid, unit=unit)
|
||||||
|
# Note: Bug#2028683 - data may not be available if the certificates
|
||||||
|
# relation hasn't been populated by the providing charm. If no 'ca'
|
||||||
|
# in the data then don't attempt the bundle at all.
|
||||||
|
if data.get('ca'):
|
||||||
if data.get(raw_certs_key):
|
if data.get(raw_certs_key):
|
||||||
bundles.append({
|
bundles.append({
|
||||||
'ca': data['ca'],
|
'ca': data['ca'],
|
||||||
'chain': data.get('chain'),
|
'chain': data.get('chain'),
|
||||||
'certs': json.loads(data[raw_certs_key])})
|
'certs': json.loads(data[raw_certs_key])
|
||||||
|
})
|
||||||
elif is_legacy_request:
|
elif is_legacy_request:
|
||||||
bundles.append({
|
bundles.append({
|
||||||
'ca': data['ca'],
|
'ca': data['ca'],
|
||||||
'chain': data.get('chain'),
|
'chain': data.get('chain'),
|
||||||
'certs': {sent['common_name']:
|
'certs': {
|
||||||
{'cert': data.get(local_name + '.server.cert'),
|
sent['common_name']: {
|
||||||
'key': data.get(local_name + '.server.key')}}})
|
'cert': data.get(local_name + '.server.cert'),
|
||||||
|
'key': data.get(local_name + '.server.key')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return bundles
|
return bundles
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ OPENSTACK_CODENAMES = OrderedDict([
|
||||||
('2022.1', 'yoga'),
|
('2022.1', 'yoga'),
|
||||||
('2022.2', 'zed'),
|
('2022.2', 'zed'),
|
||||||
('2023.1', 'antelope'),
|
('2023.1', 'antelope'),
|
||||||
|
('2023.2', 'bobcat'),
|
||||||
])
|
])
|
||||||
|
|
||||||
# The ugly duckling - must list releases oldest to newest
|
# The ugly duckling - must list releases oldest to newest
|
||||||
|
|
|
@ -32,6 +32,7 @@ UBUNTU_RELEASES = (
|
||||||
'jammy',
|
'jammy',
|
||||||
'kinetic',
|
'kinetic',
|
||||||
'lunar',
|
'lunar',
|
||||||
|
'mantic',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -521,6 +522,41 @@ _KV = None
|
||||||
|
|
||||||
def kv():
|
def kv():
|
||||||
global _KV
|
global _KV
|
||||||
|
|
||||||
|
# If we are running unit tests, it is useful to go into memory-backed KV store to
|
||||||
|
# avoid concurrency issues when running multiple tests. This is not a
|
||||||
|
# problem when juju is running normally.
|
||||||
|
|
||||||
|
env_var = os.environ.get("CHARM_HELPERS_TESTMODE", "auto").lower()
|
||||||
|
if env_var not in ["auto", "no", "yes"]:
|
||||||
|
logging.warning(f"Unknown value for CHARM_HELPERS_TESTMODE '{env_var}', assuming 'no'")
|
||||||
|
env_var = "no"
|
||||||
|
|
||||||
|
if env_var == "no":
|
||||||
|
in_memory_db = False
|
||||||
|
elif env_var == "yes":
|
||||||
|
in_memory_db = True
|
||||||
|
elif env_var == "auto":
|
||||||
|
# If UNIT_STATE_DB is set, respect this request
|
||||||
|
if "UNIT_STATE_DB" in os.environ:
|
||||||
|
in_memory_db = False
|
||||||
|
# Autodetect normal juju execution by looking for juju variables
|
||||||
|
elif "JUJU_CHARM_DIR" in os.environ or "JUJU_UNIT_NAME" in os.environ:
|
||||||
|
in_memory_db = False
|
||||||
|
else:
|
||||||
|
# We are probably running in unit test mode
|
||||||
|
logging.warning("Auto-detected unit test environment for KV store.")
|
||||||
|
in_memory_db = True
|
||||||
|
else:
|
||||||
|
# Help the linter realise that in_memory_db is always set
|
||||||
|
raise Exception("Cannot reach this line")
|
||||||
|
|
||||||
if _KV is None:
|
if _KV is None:
|
||||||
|
if in_memory_db:
|
||||||
|
_KV = Storage(":memory:")
|
||||||
|
else:
|
||||||
_KV = Storage()
|
_KV = Storage()
|
||||||
|
else:
|
||||||
|
if in_memory_db and _KV.db_path != ":memory:":
|
||||||
|
logging.warning("Running with in_memory_db and KV is not set to :memory:")
|
||||||
return _KV
|
return _KV
|
||||||
|
|
|
@ -238,6 +238,14 @@ CLOUD_ARCHIVE_POCKETS = {
|
||||||
'antelope/proposed': 'jammy-proposed/antelope',
|
'antelope/proposed': 'jammy-proposed/antelope',
|
||||||
'jammy-antelope/proposed': 'jammy-proposed/antelope',
|
'jammy-antelope/proposed': 'jammy-proposed/antelope',
|
||||||
'jammy-proposed/antelope': 'jammy-proposed/antelope',
|
'jammy-proposed/antelope': 'jammy-proposed/antelope',
|
||||||
|
# bobcat
|
||||||
|
'bobcat': 'jammy-updates/bobcat',
|
||||||
|
'jammy-bobcat': 'jammy-updates/bobcat',
|
||||||
|
'jammy-bobcat/updates': 'jammy-updates/bobcat',
|
||||||
|
'jammy-updates/bobcat': 'jammy-updates/bobcat',
|
||||||
|
'bobcat/proposed': 'jammy-proposed/bobcat',
|
||||||
|
'jammy-bobcat/proposed': 'jammy-proposed/bobcat',
|
||||||
|
'jammy-proposed/bobcat': 'jammy-proposed/bobcat',
|
||||||
|
|
||||||
# OVN
|
# OVN
|
||||||
'focal-ovn-22.03': 'focal-updates/ovn-22.03',
|
'focal-ovn-22.03': 'focal-updates/ovn-22.03',
|
||||||
|
@ -270,6 +278,7 @@ OPENSTACK_RELEASES = (
|
||||||
'yoga',
|
'yoga',
|
||||||
'zed',
|
'zed',
|
||||||
'antelope',
|
'antelope',
|
||||||
|
'bobcat',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,6 +307,7 @@ UBUNTU_OPENSTACK_RELEASE = OrderedDict([
|
||||||
('jammy', 'yoga'),
|
('jammy', 'yoga'),
|
||||||
('kinetic', 'zed'),
|
('kinetic', 'zed'),
|
||||||
('lunar', 'antelope'),
|
('lunar', 'antelope'),
|
||||||
|
('mantic', 'bobcat'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue