Skip to content

Commit 8e6dab7

Browse files
committed
Update endpoints only if controller model can be accessed
Fixes #998 ControllerAPIInfoForModels call requires the uuid of the controller model, and if the user doesn't have at least read access, they won't be able to have that, and the update_endpoint call at the end of a regular connection fails.
1 parent e203dd7 commit 8e6dab7

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

juju/controller.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,14 @@ async def connect(self, *args, **kwargs):
140140
await self.update_endpoints()
141141

142142
async def update_endpoints(self):
143-
info = await self.info()
144-
self._connector._connection.endpoints = [
145-
(e, info.results[0].cacert)
146-
for e in info.results[0].addresses
147-
]
143+
try:
144+
info = await self.info()
145+
self._connector._connection.endpoints = [
146+
(e, info.results[0].cacert)
147+
for e in info.results[0].addresses
148+
]
149+
except errors.JujuPermissionError:
150+
pass
148151

149152
async def connect_current(self):
150153
"""
@@ -288,6 +291,8 @@ async def info(self):
288291
"""
289292
log.debug('Getting information')
290293
uuids = await self.model_uuids()
294+
if 'controller' not in uuids:
295+
raise errors.JujuPermissionError('Requires access to controller model.')
291296
controller_facade = client.ControllerFacade.from_connection(self.connection())
292297
params = [client.Entity(tag.model(uuids["controller"]))]
293298
return await controller_facade.ControllerAPIInfoForModels(entities=params)

0 commit comments

Comments
 (0)