[wallaby] 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/829 Closes-Bug: #2028683 Change-Id: Icf929c3c623ef1011f29a7c20ea2c9ac6df706f1
This commit is contained in:
parent
4fc5070d5c
commit
789f6b9287
@ -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
|
||||||
|
|
||||||
|
@ -2604,6 +2604,23 @@ def get_subordinate_release_packages(os_release, package_type='deb'):
|
|||||||
return SubordinatePackages(install, purge)
|
return SubordinatePackages(install, purge)
|
||||||
|
|
||||||
|
|
||||||
|
def get_subordinate_services():
|
||||||
|
"""Iterate over subordinate relations and get service information.
|
||||||
|
|
||||||
|
In a similar fashion as with get_subordinate_release_packages(),
|
||||||
|
principle charms can retrieve a list of services advertised by their
|
||||||
|
subordinate charms. This is useful to know about subordinate services when
|
||||||
|
pausing, resuming or upgrading a principle unit.
|
||||||
|
|
||||||
|
:returns: Name of all services advertised by all subordinates
|
||||||
|
:rtype: Set[str]
|
||||||
|
"""
|
||||||
|
services = set()
|
||||||
|
for rdata in container_scoped_relation_get('services'):
|
||||||
|
services |= set(json.loads(rdata or '[]'))
|
||||||
|
return services
|
||||||
|
|
||||||
|
|
||||||
os_restart_on_change = partial(
|
os_restart_on_change = partial(
|
||||||
pausable_restart_on_change,
|
pausable_restart_on_change,
|
||||||
can_restart_now_f=deferred_events.check_and_record_restart_request,
|
can_restart_now_f=deferred_events.check_and_record_restart_request,
|
||||||
|
@ -52,7 +52,7 @@ def _snap_exec(commands):
|
|||||||
:param commands: List commands
|
:param commands: List commands
|
||||||
:return: Integer exit code
|
:return: Integer exit code
|
||||||
"""
|
"""
|
||||||
assert type(commands) == list
|
assert isinstance(commands, list)
|
||||||
|
|
||||||
retry_count = 0
|
retry_count = 0
|
||||||
return_code = None
|
return_code = None
|
||||||
|
3
tox.ini
3
tox.ini
@ -84,7 +84,8 @@ commands = stestr run --slowest {posargs}
|
|||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps = flake8==3.9.2
|
deps = flake8==3.9.2
|
||||||
charm-tools==2.8.3
|
PyYAML==6.0.1
|
||||||
|
charm-tools==2.8.6
|
||||||
commands = flake8 {posargs} hooks unit_tests tests actions lib files
|
commands = flake8 {posargs} hooks unit_tests tests actions lib files
|
||||||
charm-proof
|
charm-proof
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user