It looks like there is a specific code path for a subordinate to find out information about the principle for juju 1.X:
def principal_unit():
"""Returns the principal unit of this unit, otherwise None"""
# Juju 2.2 and above provides JUJU_PRINCIPAL_UNIT
principal_unit = os.environ.get('JUJU_PRINCIPAL_UNIT', None)
# If it's empty, then this unit is the principal
if principal_unit == '':
return os.environ['JUJU_UNIT_NAME']
elif principal_unit is not None:
return principal_unit
# For Juju 2.1 and below, let's try work out the principle unit by
# the various charms' metadata.yaml.
for reltype in relation_types():
for rid in relation_ids(reltype):
for unit in related_units(rid):
md = _metadata_unit(unit)
if not md: continue subordinate = md.pop('subordinate', None)
if not subordinate: return unit
return None
It looks like the principle is returning invalid yaml.
It looks like there is a specific code path for a subordinate to find out information about the principle for juju 1.X:
def principal_unit(): get('JUJU_ PRINCIPAL_ UNIT', None) 'JUJU_UNIT_ NAME'] ids(reltype) : unit(unit)
continue
subordinate = md.pop( 'subordinate' , None)
return unit
"""Returns the principal unit of this unit, otherwise None"""
# Juju 2.2 and above provides JUJU_PRINCIPAL_UNIT
principal_unit = os.environ.
# If it's empty, then this unit is the principal
if principal_unit == '':
return os.environ[
elif principal_unit is not None:
return principal_unit
# For Juju 2.1 and below, let's try work out the principle unit by
# the various charms' metadata.yaml.
for reltype in relation_types():
for rid in relation_
for unit in related_units(rid):
md = _metadata_
if not md:
if not subordinate:
return None
It looks like the principle is returning invalid yaml.