-
Notifications
You must be signed in to change notification settings - Fork 99
High availability support #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,13 @@ async def connect(self, **kwargs): | |
| for macaroon in kwargs.pop('macaroons'): | ||
| jar.set_cookie(go_to_py_cookie(macaroon)) | ||
| self._connection = await Connection.connect(**kwargs) | ||
| controller = self.jujudata.controllers()[ | ||
| self.jujudata.current_controller() | ||
| ] | ||
| self._connection.endpoints = [ | ||
| (e, controller["ca-cert"]) | ||
| for e in controller["api-endpoints"] | ||
| ] | ||
|
Comment on lines
+73
to
+76
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SimonRichardson I would like to set the endpoints within the Connection, but the problem is that if I get the controller from the connection, it enters into a loop. If you come up with a better solution, let me know :-) |
||
|
|
||
| async def disconnect(self): | ||
| """Shut down the watcher task and close websockets. | ||
|
|
@@ -86,13 +93,11 @@ async def connect_controller(self, controller_name=None, specified_facades=None) | |
| raise JujuConnectionError('No current controller') | ||
|
|
||
| controller = self.jujudata.controllers()[controller_name] | ||
| # TODO change Connection so we can pass all the endpoints | ||
| # instead of just the first. | ||
| endpoint = controller['api-endpoints'][0] | ||
| endpoints = controller['api-endpoints'] | ||
| accounts = self.jujudata.accounts().get(controller_name, {}) | ||
|
|
||
| await self.connect( | ||
| endpoint=endpoint, | ||
| endpoint=endpoints, | ||
| uuid=None, | ||
| username=accounts.get('user'), | ||
| password=accounts.get('password'), | ||
|
|
@@ -119,9 +124,7 @@ async def connect_model(self, model_name=None): | |
| if controller is None: | ||
| raise JujuConnectionError('Controller {} not found'.format( | ||
| controller_name)) | ||
| # TODO change Connection so we can pass all the endpoints | ||
| # instead of just the first one. | ||
| endpoint = controller['api-endpoints'][0] | ||
| endpoints = controller['api-endpoints'] | ||
| account = self.jujudata.accounts().get(controller_name, {}) | ||
| models = self.jujudata.models().get(controller_name, {}).get('models', | ||
| {}) | ||
|
|
@@ -135,7 +138,7 @@ async def connect_model(self, model_name=None): | |
| # and also remove the need for base.CleanModel to | ||
| # subclass JujuData. | ||
| await self.connect( | ||
| endpoint=endpoint, | ||
| endpoint=endpoints, | ||
| uuid=models[model_name]['uuid'], | ||
| username=account.get('user'), | ||
| password=account.get('password'), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we can get rid of
self.endpointaltogether and then sayself.endpoints = [endpoint]. That way we reduce the number ofif isinstance(endpoint, str)etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this: self.endpoints = [endpoint]
But removing the self.endpoint is more complicated, because that variable is used to by the class to know to which endpoint in particular it is connected to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmmmm but if I do [endpoint], and endpoint is a list, then self.endpoints will be [["endpoint1", ...]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davigar15 then we need to update
self.endpointto always be the one it's connected to. That way we're always in sync.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimonRichardson That is updated in line 629, in the _connect function.
Every time libjuju reconnects, it executes the function _connect, and then this is executed:
self.endpoint = result[2]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent.