Closed gnuoy closed 4 years ago
The bundles used in the example are:
http://paste.ubuntu.com/p/3BY9YwFYXC/ (bionic-train-gr-r1.yaml) http://paste.ubuntu.com/p/QwK3XFwSwT/ (bionic-train-gr-r2.yaml)
juju add-model swift-gr-region1
juju add-model swift-gr-region2
juju deploy -m swift-gr-region1 ./bionic-train-gr-r1.yaml
juju deploy -m swift-gr-region2 ./bionic-train-gr-r2.yaml
juju offer swift-gr-region1.swift-storage-region1-zone1:swift-storage
Application "swift-storage-region1-zone1" endpoints [swift-storage] available at "admin/swift-gr-region1.swift-storage-region1-zone1"
juju offer swift-gr-region1.swift-storage-region1-zone2:swift-storage
Application "swift-storage-region1-zone2" endpoints [swift-storage] available at "admin/swift-gr-region1.swift-storage-region1-zone2"
juju offer swift-gr-region1.swift-storage-region1-zone3:swift-storage
Application "swift-storage-region1-zone3" endpoints [swift-storage] available at "admin/swift-gr-region1.swift-storage-region1-zone3"
juju add-relation -m swift-gr-region2 swift-proxy-region2 admin/swift-gr-region1.swift-storage-region1-zone1
juju add-relation -m swift-gr-region2 swift-proxy-region2 admin/swift-gr-region1.swift-storage-region1-zone2
juju add-relation -m swift-gr-region2 swift-proxy-region2 admin/swift-gr-region1.swift-storage-region1-zone3
Once the CMRs have been added the bug appears:
./lib-juju-repre.py
Traceback (most recent call last):
File "./lib-juju-repre.py", line 12, in <module>
loop.run(deploy())
File "/home/ubuntu/work/bugs/libjuju-issues-366/venv3/lib/python3.6/site-packages/juju/loop.py", line 38, in run
raise task.exception()
File "./lib-juju-repre.py", line 9, in deploy
print(model.applications['swift-storage-region1-zone1'].relations)
File "/home/ubuntu/work/bugs/libjuju-issues-366/venv3/lib/python3.6/site-packages/juju/application.py", line 58, in relations
return [rel for rel in self.model.relations if rel.matches(self.name)]
File "/home/ubuntu/work/bugs/libjuju-issues-366/venv3/lib/python3.6/site-packages/juju/application.py", line 58, in <listcomp>
return [rel for rel in self.model.relations if rel.matches(self.name)]
File "/home/ubuntu/work/bugs/libjuju-issues-366/venv3/lib/python3.6/site-packages/juju/relation.py", line 110, in matches
if app_name == endpoint.application.name and \
File "/home/ubuntu/work/bugs/libjuju-issues-366/venv3/lib/python3.6/site-packages/juju/relation.py", line 23, in application
raise KeyError(app_name)
KeyError: 'remote-a24d164799004bc889a3ec925e44bee6'
@gnuoy is there any chance you can make available the bigger bundle, so I can try and replicate where the gap is, with my patch in #367?
Hi @SimonRichardson I'm using the deployment I mentioned earlier *1. This is what I see when I use your branch:
$ virtualenv -ppython3 venv
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/ubuntu/cmr-test/venv/bin/python3
Also creating executable in /home/ubuntu/cmr-test/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
$ source venv/bin/activate
$ cat sr.txt
git+https://github.com/SimonRichardson/python-libjuju.git@key-error#egg=juju
$ pip install -r sr.txt
...
$ cat ./lib-juju-repre.py
#!/usr/bin/env python3
from juju import loop
from juju.model import Model
async def deploy():
model = Model()
await model.connect('swift-gr-region2')
print("Model2 swift-storage-region2-zone1 relations:")
print(model.applications['swift-storage-region2-zone1'].relations)
await model.disconnect()
print()
model = Model()
await model.connect('swift-gr-region1')
print("Model1 swift-storage-region1-zone1 relations:")
print(model.applications['swift-storage-region1-zone1'].relations)
await model.disconnect()
if __name__ == '__main__':
loop.run(deploy())
$ ./lib-juju-repre.py
Model2 swift-storage-region2-zone1 relations:
[<Relation id=1 swift-proxy-region2:swift-storage swift-storage-region2-zone1:swift-storage>]
Model1 swift-storage-region1-zone1 relations:
Traceback (most recent call last):
File "./lib-juju-repre.py", line 22, in <module>
loop.run(deploy())
File "/home/ubuntu/cmr-test/venv/lib/python3.6/site-packages/juju/loop.py", line 38, in run
raise task.exception()
File "./lib-juju-repre.py", line 18, in deploy
print(model.applications['swift-storage-region1-zone1'].relations)
File "/home/ubuntu/cmr-test/venv/lib/python3.6/site-packages/juju/application.py", line 58, in relations
return [rel for rel in self.model.relations if rel.matches(self.name)]
File "/home/ubuntu/cmr-test/venv/lib/python3.6/site-packages/juju/application.py", line 58, in <listcomp>
return [rel for rel in self.model.relations if rel.matches(self.name)]
File "/home/ubuntu/cmr-test/venv/lib/python3.6/site-packages/juju/relation.py", line 115, in matches
if endpoint.application is None:
File "/home/ubuntu/cmr-test/venv/lib/python3.6/site-packages/juju/relation.py", line 26, in application
raise JujuEntityNotFoundError(app_name, ["application", "remoteApplication"])
juju.errors.JujuEntityNotFoundError: Entity not found: remote-412f14470cba4f2a8624e3f2ce164af6
*1 https://github.com/juju/python-libjuju/issues/366#issuecomment-555967400
@gnuoy this is amazing, thank-you, I'll try and replicate that this afternoon.
When querying the relations of a unit when CMRs are present libjuju throws a KeyError exception: