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

CLI sessions: handle case where retry is not passed as an argument #364

Merged
merged 1 commit into from
Mar 3, 2023

Conversation

sbesson
Copy link
Member

@sbesson sbesson commented Feb 21, 2023

Some logic was introduced in #283 to allow auto-retries in the CLI sessions plugin. This new functionality is disabled by default. As can be seen in the original PR, most of the testing has been done using omero sessions login where the functionality was introduced.

Most CLI plugins can inherit the login mechanism: the addition of add_login_arguments() in the CLI plugin sub-parser means the self.ctx.conn(args) can then use self.controls["sessions"].login(args).

As the --retry argument was only added to the sessions plugin, a misleading error message can be printed under some scenarios. The most typical ones and the easiest to reproduce is to enter an incorrect password. The login command produces the expected behavior with 3 tries by defaut:

(venv3) [sbesson@prod114-omeroreadwrite ~]$ omero login public@localhost -C
Password:
Password check failed for 'public': [id=52]
Password:
Password check failed for 'public': [id=52]
Password:
3 incorrect password attempts

But any other command will fail immediately with a cryptic InternalException

(venv3) [sbesson@prod114-omeroreadwrite ~]$ omero hql 'select * from Image i' -u public -s localhost -C
Password:
InternalException: Failed to connect: 'Namespace' object has no attribute 'retry'

e5ac9c6 proposes one way to fix this issue by adding an additional check for the existence of the retry in the var(args) dictionary and would make the two examples above behave identically.
An alternate strategy would be to add --retry to Parser. add_login_arguments and allow all sub-commands to set the value.

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

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

I wouldn't have any objections to also adding to the add_login_arguments method but I can't immediately think of a case where I would use it. (Perhaps some form of one-liner...)

@sbesson
Copy link
Member Author

sbesson commented Mar 2, 2023

but I can't immediately think of a case where I would use it.

Agreed and this is likely why I didn't go and implement this solution at first. The omero sessions login --retry logic was introduced for a fairly specific use case. I'd be fine with waiting until someone comes with a concrete scenario before adding an optional argument to almost all CLI plugins

@joshmoore joshmoore merged commit 007038a into ome:master Mar 3, 2023
@sbesson sbesson deleted the retry_exception branch March 3, 2023 10:35
@sbesson
Copy link
Member Author

sbesson commented Jun 21, 2023

We had some users stumbling across the InternalException: Failed to connect: 'Namespace' object has no attribute 'retry' error and I just realised this has been merged but not released yet.

@joshmoore @jburel is there a roadmap/timeline for the next OMERO.py release? I realise there are a few ongoing investigations including #371 and #370 but looking at v5.13.1...d5ca72f, we could certainly cut a patch release with the integrated changes.

@jburel
Copy link
Member

jburel commented Jun 21, 2023

It will make sense to cut a patch release. Do you want to take care of it?

@sbesson
Copy link
Member Author

sbesson commented Jun 21, 2023

Sure, I'll open a changelog PR shortly

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