build_facades logic doesn't account for discharge-required-error #114

Closed
johnsca opened this Issue Apr 26, 2017 · 0 comments

Comments

Projects
None yet
1 participant
Member

johnsca commented Apr 26, 2017

When connecting to JAAS, sometimes one of the endpoints will not have a discharged macaroon and we'll need to try another one. This isn't handled properly by the build_facades logic, and leads to this failure:

2017-04-26 12:28:44,633 [INFO] conjure-up/ghost - websocket: connection.py:161 - Driver connected to juju wss://1.us-east-1.aws.jaas.jujucharms.com:443/model/0b51d501-1f74-4ca2-800d-0461c0c6eef9/api
2017-04-26 12:28:44,745 [INFO] conjure-up/ghost - websocket: connection.py:440 - {'discharge-required': {'caveats': [{'cid': 'time-before '
                                            '2017-04-26T17:28:44.728481186Z'},
                                    {'cid': '...',
                                     'cl': 'https://api.jujucharms.com/identity',
                                     'vid': '...'}],
                        'identifier': 'api-login',
                        'location': 'juju model '
                                    'd5549d83-423c-43c7-8a87-238a312dcf18',
                        'signature': '...'},
 'discharge-required-error': 'verification failed: macaroon not found in '
                             'storage'}
2017-04-26 12:28:44,745 [ERROR] conjure-up/ghost - juju.model: model.py:648 - Error in watcher
Traceback (most recent call last):
  File "/home/johnsca/juju/conjure-up/conjure-dev/lib/python3.5/site-packages/juju/client/connection.py", line 442, in build_facades
    self.facades = VERSION_MAP[self.info['server-version']]
KeyError: 'server-version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/johnsca/juju/conjure-up/conjure-dev/lib/python3.5/site-packages/juju/model.py", line 624, in _start_watch
    self._watch_conn = await self.connection.clone()
  File "/home/johnsca/juju/conjure-up/conjure-dev/lib/python3.5/site-packages/juju/client/connection.py", line 295, in clone
    self.loop,
  File "/home/johnsca/juju/conjure-up/conjure-dev/lib/python3.5/site-packages/juju/client/connection.py", line 328, in connect
    await client.login(username, password, macaroons)
  File "/home/johnsca/juju/conjure-up/conjure-dev/lib/python3.5/site-packages/juju/client/connection.py", line 469, in login
    self.build_facades(response.get('facades', {}))
  File "/home/johnsca/juju/conjure-up/conjure-dev/lib/python3.5/site-packages/juju/client/connection.py", line 446, in build_facades
    self.info['server-version']))
KeyError: 'server-version'
2017-04-26 12:29:54,745 [INFO] conjure-up/ghost - websockets.protocol: protocol.py:618 - Failing the WebSocket connection: 1006 

johnsca added a commit that referenced this issue Apr 26, 2017

Refactored login code to better handle redirects
Fixes #114: build_facades not handling discharge-required results
Fixes #115: JAAS update broke controller connections

Also ensures that the receiver and pinger tasks get cleaned up properly
when a connection is closed.

Also makes the model AllWatcher share the model connection to reduce the
number of open connections required.  The independent connection is no
longer needed since the websocket responses are properly paired with the
requests.

@johnsca johnsca closed this in #116 Apr 26, 2017

johnsca added a commit that referenced this issue Apr 26, 2017

Refactored login code to better handle redirects (#116)
Fixes #114: build_facades not handling discharge-required results
Fixes #115: JAAS update broke controller connections

Also ensures that the receiver and pinger tasks get cleaned up properly
when a connection is closed.

Also makes the model AllWatcher share the model connection to reduce the
number of open connections required.  The independent connection is no
longer needed since the websocket responses are properly paired with the
requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment