Skip to content
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

Let the client keep the session open when closing #435

Closed
wants to merge 2 commits into from

Conversation

ralt
Copy link
Contributor

@ralt ralt commented Jun 1, 2017

The use case is being able to restart a process (e.g. software upgrade)
and not losing the ephemeral nodes. The process can save the session id
and password in a file, reload them at boot time, and load the kazoo
client with the previous session id.

The use case is being able to restart a process (e.g. software upgrade)
and not losing the ephemeral nodes. The process can save the session id
and password in a file, reload them at boot time, and load the kazoo
client with the previous session id.
@ralt
Copy link
Contributor Author

ralt commented Jun 1, 2017

Following up on #409.

I'm not sure of what needs to be done with regards to the documentation, the existing one for the client looks vastly outdated, and it doesn't feel appropriate to document all of the arguments at once. :)

@ralt
Copy link
Contributor Author

ralt commented Jun 1, 2017

cc @harlowja @bbangert

@ralt
Copy link
Contributor Author

ralt commented Jun 1, 2017

The CI failures look unrelated to this PR:

test_keep_session (kazoo.tests.test_client.TestClient) ... ok

close_connection = self._send_request(
read_timeout,
connect_timeout,
) == SESSION_KEPT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit awkward, tacking on a boolean eval at the end. Can it be changed to get the response first as was done immediately above it?

@bbangert
Copy link
Member

bbangert commented Jun 1, 2017

I understand the use-case, I think the code/test looks good. I'm a bit worried about the implications, since there is no way to restore Lock's/etc or any of the recipes based on existing ephemeral nodes. It means that when the program starts up, if it had Lock nodes out there, they'll remain there, even though there's no way for this client to recover the use of them.

Does your code using this also save information upon quitting about all the ephemeral nodes and where they were? Best practice with Zookeeper has generally been to avoid attempting to recover a session, and if your process needs to exit, it's better to start over.

@bbangert
Copy link
Member

bbangert commented Jun 1, 2017

Regarding the tests, it looks like this change introduces some issues with the way the connection is handled. While the test you added passes, a lot of others no longer pass, but they passed before this change so there's definitely more work to be done as it appears to have unintended side-effects.

@ralt
Copy link
Contributor Author

ralt commented Jun 1, 2017

Does your code using this also save information upon quitting about all the ephemeral nodes and where they were?

Our code expects to find ephemeral nodes at specific places. If it's not there, we can know that one client or another lost the session, and thus act on this.

Regarding the tests, it looks like this change introduces some issues with the way the connection is handled. While the test you added passes, a lot of others no longer pass, but they passed before this change so there's definitely more work to be done as it appears to have unintended side-effects.

Hm, ok, I'll look at them. Thanks!

@bbangert
Copy link
Member

bbangert commented Jun 1, 2017

Regarding documentation, I think the only addition that would be useful is a disclaimer/warning in the doc string that using keep_session with Lock's or other recipe objects using ephemeral nodes could be problematic. Without any docs warning about this option, it seems quite easy for someone to think they do want the session to stay not understanding how bad it could be. I can't think of any other option with as much potential for issues as this one.

@bbangert
Copy link
Member

bbangert commented Jun 7, 2017

@ralt Did you want to look into fixing the tests so they pass for the others, or did the change introduce something to the connection handling too subtle to pick out easily?

@ralt
Copy link
Contributor Author

ralt commented Jun 8, 2017

@bbangert I want to look into it, just haven't had the time yet, it's a scarce resource :-)

@bbangert
Copy link
Member

@ralt I should note that it appears #305 introduced a bug with runtime error mismatches. I'm seeing if that can be cleared up, or if I'll have to revert that PR. At which point maybe this one will actually work fine with no changes.

@@ -113,7 +113,7 @@ def __init__(self, hosts='127.0.0.1:2181',
timeout=10.0, client_id=None, handler=None,
default_acl=None, auth_data=None, read_only=None,
randomize_hosts=True, connection_retry=None,
command_retry=None, logger=None, **kwargs):
command_retry=None, logger=None, keep_session=False, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)

@bbangert
Copy link
Member

Updated the base branch to trigger a test run, this should help ensure whether #305 was the issue.

@bbangert
Copy link
Member

Oh, guess not, tests still all fail.

@bbangert
Copy link
Member

Just a heads-up, we're coming up on 30 days now. I'm trying to avoid having PR's idle eternally in the backlog like this, so if you'd like to try later, a new PR can be opened when ready.

@ralt
Copy link
Contributor Author

ralt commented Jun 22, 2017

Yes, let me close that and I'll open a new PR when I'll have some time to look at the tests.

@ralt ralt closed this Jun 22, 2017
@bbangert
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants