-
Notifications
You must be signed in to change notification settings - Fork 10
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
Refactor redfish login and logout methods. #64
Conversation
fcc3722
to
d750bcc
Compare
Note that I edit my PR description to indicate a potential loop hole that we can't really fix. The workaround is to increase the redfish timeout so that the case I mentioned can be significantly reduced. |
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.
Do not agree with defining the context manager, but not using it, since it can fail. But I do not see this blocker issue for now.
We shouldn't simply remove it because we don't use it, since it will cause a backward compatibility issue (just in case other users are using this repo as a library). |
I never suggested that, but if anyone is using as lib, they will hit same issue and the fix will be same as you are doing "not using context manager". |
After reading through the comments and thinking about this,
Please correct me if I'm wrong in any of the assumptions in my summary. |
For example if you set a login timeout to 1s, and you think your server can handles the login in 1s, that's fine. However, if the server take too long to respond (say 5s), then [1] https://github.com/DMTF/python-redfish-library/blob/main/src/redfish/rest/v1.py#L1027 |
redfish context manager could potentially failed during __enter__ which might causes the __exit__ function never called. We should ensure the redfish client is logged out in any exception. This can be achieved by adding a finally block to the try-except block.
deeb6d6
to
bfb2b3e
Compare
Rebased onto ba509b6 |
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.
LGTM overall, thanks :)
I do not want to block this, and I need to focus on other things.
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.
LGTM. Just a small comment that it's not relevant.
The redfish context manager could potentially failed during
__enter__
which might causes the__exit__
function never called. We should ensure the redfish client is logged out in any exception. This can be achieved by adding a finally block to the try-except block.Note that even if the
login()
crashes, the server might still recognize the login as successful, and a force logout might not work since we did not get the response from the initiallogin()
. For example, if a login is timed out, and the exporter service raise and catch the exception, but the response from thelogin()
will not set thesession_key
orsession_location
in the response object (since we never get back a response), so a forcelogout()
will not be able to perform aDELETE
(using thesession_location
) on the server to close the connection. This is an inherent issue on the redfish library that probably cannot be easily fixedCloses: canonical/hardware-observer-operator#136