The zaza testing software has had a function named get_subordinates() which relies on finding the charm's name (not the app name) within the 'subordinates' tree, more details of the implementation can be found at https://github.com/openstack-charmers/zaza/blob/master/zaza/utilities/juju.py#L445
Here there is a test case that uses libjuju:
Steps:
juju add-model mymodel
juju deploy --series focal ch:ubuntu
juju deploy --series focal ch:ntp
juju add-relation ubuntu ntp
juju wait
cat << EOF > my.py
import asyncio
import os
from juju.model import Model
async def main():
model = Model()
await model.connect_model(os.environ['JUJU_MODEL'])
status = await model.get_status()
print(status.applications['ubuntu']['units']['ubuntu/0']['subordinates'])
print(status.applications['ntp']['units'])
assert status.applications['ubuntu']['units']['ubuntu/0']['subordinates']['ntp/0']['charm'], "The charm field shouldn't be empty"
if __name__ == "__main__":
asyncio.run(main())
EOF
JUJU_MODEL=mymodel python3 my.py
Expected result:
the 'charm' field available at status.applications['ubuntu']['units']['ubuntu/0']['subordinates']['ntp/0']['charm'] contains the charm used to deploy that unit (e.g. ch:amd64/focal/ntp-49 ).
Actual result:
the 'charm' field is empty and only set at the same level of the units key (e.g. status['ntp']['charm'])
my environment is running juju 2.9.34
the issue is reproducible in 2.9.33 too: /github. com/openstack- charmers/ zaza/runs/ 7955966658? check_suite_ focus=true# step:4: 831 /github. com/openstack- charmers/ zaza/runs/ 7955966658? check_suite_ focus=true# step:5: 24
https:/
https:/