[zed] 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/826 Closes-Bug: #2028683 Change-Id: Iac8a15c075800dbb44ac498c94c6e917d45614d1
This commit is contained in:
parent
fd24b08275
commit
245a2e32d5
@ -414,18 +414,27 @@ def get_requests_for_local_unit(relation_name=None):
|
||||
is_legacy_request = set(sent).intersection(legacy_keys)
|
||||
for unit in related_units(rid):
|
||||
data = relation_get(rid=rid, unit=unit)
|
||||
if data.get(raw_certs_key):
|
||||
bundles.append({
|
||||
'ca': data['ca'],
|
||||
'chain': data.get('chain'),
|
||||
'certs': json.loads(data[raw_certs_key])})
|
||||
elif is_legacy_request:
|
||||
bundles.append({
|
||||
'ca': data['ca'],
|
||||
'chain': data.get('chain'),
|
||||
'certs': {sent['common_name']:
|
||||
{'cert': data.get(local_name + '.server.cert'),
|
||||
'key': data.get(local_name + '.server.key')}}})
|
||||
# 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):
|
||||
bundles.append({
|
||||
'ca': data['ca'],
|
||||
'chain': data.get('chain'),
|
||||
'certs': json.loads(data[raw_certs_key])
|
||||
})
|
||||
elif is_legacy_request:
|
||||
bundles.append({
|
||||
'ca': data['ca'],
|
||||
'chain': data.get('chain'),
|
||||
'certs': {
|
||||
sent['common_name']: {
|
||||
'cert': data.get(local_name + '.server.cert'),
|
||||
'key': data.get(local_name + '.server.key')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return bundles
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user