-
Notifications
You must be signed in to change notification settings - Fork 32
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
login: add --retry=seconds option to login #283
Conversation
This should replace the wait.sh-stype scripts that exist in multiple (especially docker) repositories. Example output: ``` $ omero sessions login -w omero root@localhost --retry=100 Previous session expired for root on localhost:4064 09:41:30.959913: Login retry #1 in 3s 09:41:33.977181: Login retry #2 in 3s ... 09:41:58.129038: Login retry #10 in 3s WARNING:omero.client:None - createSession retry: 1 WARNING:omero.client:None - createSession retry: 2 09:42:17.100098: Login retry #11 in 3s Created session for root@localhost:4064. Idle timeout: 10 min. Current group: system ```` see: https://github.com/ome/omero-server-docker/blob/master/test_login.sh
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.
A fairly basic test of the functionality, trying to create a session while stopping and restarting a server completed as expected:
(.venv3) bash-4.2$ omero sessions login root@localhost -w omero -C
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
InternalException: Failed to connect: Ice.ConnectFailedException:
Network is unreachable
(.venv3) bash-4.2$ omero sessions login root@localhost -w omero -C --retry=5
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:20.723095: Login retry #1 in 3s
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:23.736698: Login retry #2 in 3s
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
InternalException: Failed to connect: Ice.ConnectFailedException:
Network is unreachable
(.venv3) bash-4.2$ omero sessions login root@localhost -w omero -C --retry=60
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:36.277700: Login retry #1 in 3s
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:39.293634: Login retry #2 in 3s
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:42.309487: Login retry #3 in 3s
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:45.325290: Login retry #4 in 3s
WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.ConnectFailedException'>
21:32:48.342630: Login retry #5 in 3s
21:32:59.326895: Login retry #6 in 3s
Created session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Overall the new logic looks straightforward and I concur having a built-in way to retry a connection feels generally useful.
One inline suggestion about making the new option available outside the omero sessions login
subcommand. More generally, are we expecting the new option to be part of the generic session arguments that can be passed to most CLI commands?
src/omero/plugins/sessions.py
Outdated
@@ -200,6 +201,9 @@ def _configure(self, parser): | |||
logout = parser.add( | |||
sub, self.logout, "Logout and remove current session key") | |||
self._configure_login(login) | |||
login.add_argument( | |||
"--retry", nargs="?", type=int, default=0, | |||
help="Number of seconds to retry login (default: no retry)") |
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.
Should this block be set up in the _configure_login
instead? The immediate benefit is that the omero login
alias to omero sessions login
would also recognize the new retry argument.
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.
Good point.
I'll push a refactoring for @sbesson's fairly minor issue but on the API front, all are happy?
|
Thanks, the option is now properly exposed
Thinking more of the question raised #283 (comment), I tried to look at similar examples. Probably the most relevant to this conversation curl. A few thoughts:
|
Seems like this is the biggest issue to address since a change would be breaking. |
Any thoughts, @sbesson ? |
From my side, happy to start with a simple fixed delay and capping based on the total retry time. We can add more complex algorithm or cap the number of retries as follow-up. I tried to spend a bit of time looking at other examples. Unfortunately, there is no real unified way to specify retry via command-line. Looking at a few examples:
In the absence of a compromise, maybe |
Ok. Sounds like we have a path forward if we want to become more explicit. Merging and getting this released. |
This should replace the wait.sh-stype scripts that exist in
multiple (especially docker) repositories.
Example output:
see: https://github.com/ome/omero-server-docker/blob/master/test_login.sh