Skip to content

Commit f31ef16

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 2990139 commit f31ef16

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
@@ -139,11 +139,14 @@ async def connect(self, *args, **kwargs):
139139
await self.update_endpoints()
140140

141141
async def update_endpoints(self):
142-
info = await self.info()
143-
self._connector._connection.endpoints = [
144-
(e, info.results[0].cacert)
145-
for e in info.results[0].addresses
146-
]
142+
try:
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+
]
148+
except errors.JujuPermissionError:
149+
pass
147150

148151
async def connect_current(self):
149152
"""
@@ -281,6 +284,8 @@ async def info(self):
281284
"""
282285
log.debug('Getting information')
283286
uuids = await self.model_uuids()
287+
if 'controller' not in uuids:
288+
raise errors.JujuPermissionError('Requires access to controller model.')
284289
controller_facade = client.ControllerFacade.from_connection(self.connection())
285290
params = [client.Entity(tag.model(uuids["controller"]))]
286291
return await controller_facade.ControllerAPIInfoForModels(entities=params)

0 commit comments

Comments
 (0)