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

CA-388527 xsconsole: 'timed out' when creating an ISCSI SR #42

Merged

Conversation

stephenchengCloud
Copy link
Contributor

@stephenchengCloud stephenchengCloud commented May 23, 2024

The XSConsoleAuth set socket timout value to 15 seconds,
and it's not enough for the SR.create.
Use xenapi.Async call instead.

Test passed:
image

@liulinC liulinC requested a review from robhoes May 23, 2024 09:56
@rosslagerwall
Copy link
Contributor

If it fails with a 15 second timeout on one system, it seems likely that it will fail even with a 20 second timeout on another system.

It seems pretty weird setting such a low timeout, not just on a specific socket but as the default timeout for all Python sockets in the program.

I think it would be better to not change the default socket timeout and rather just set an appropriate timeout on certain specific operations where it is needed.

@stephenchengCloud
Copy link
Contributor Author

If it fails with a 15 second timeout on one system, it seems likely that it will fail even with a 20 second timeout on another system.

It seems pretty weird setting such a low timeout, not just on a specific socket but as the default timeout for all Python sockets in the program.

I think it would be better to not change the default socket timeout and rather just set an appropriate timeout on certain specific operations where it is needed.

I looked into the code, and it turned out that the default socket timeout was added in CA-69997 for a scenario that "xsconsole is already running when the master's IP is changed". I don't think we can remove socket.setdefaulttimeout(15)

I also noticed that the Auth class (where to setdefaulttimeout) is a singleton, so it is impossible to set a specific timeout for SR.create operation.

Any suggestion?

@rosslagerwall
Copy link
Contributor

I looked into the code, and it turned out that the default socket timeout was added in CA-69997 for a scenario that "xsconsole is already running when the master's IP is changed". I don't think we can remove socket.setdefaulttimeout(15)

That might be there for a reason but it still seems like a hack at best. I guess it might be quite a lot of work to fix it.

Another option for cases where the XAPI call is expected to take a long time would be to use an async call and then poll the task at some interval until it completes. That should avoid hitting a socket timeout even if the task takes longer than 15 or 20 seconds. Polling is not the best but I expect these kinds of calls from xsconsole would be rare.

@stephenchengCloud
Copy link
Contributor Author

Thanks for the advice. I'll try the polling.

@stephenchengCloud stephenchengCloud force-pushed the private/stephenche/CA-388527 branch 2 times, most recently from c10c58c to 9aa8f69 Compare June 4, 2024 08:25
@stephenchengCloud
Copy link
Contributor Author

Use xenapi.Async call to avoid socket timeout.
Test Passed:
image

if self.Completed():
result = self.completionStatus
else:
result= self.session.xenapi.task.get_status(self.hotOpaqueRef.OpaqueRef())
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously this returned the status which seems wrong. Was that used anywhere or was it just a latent bug?

Copy link
Contributor Author

@stephenchengCloud stephenchengCloud Jun 5, 2024

Choose a reason for hiding this comment

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

I believe this is a bug, and I checked that the function was not used.

else:
result= self.session.xenapi.task.get_status(self.hotOpaqueRef.OpaqueRef())
return HotOpaqueRef(result, 'any')
return self.result
Copy link
Contributor

Choose a reason for hiding this comment

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

For synchronous tasks, is it guaranteed that self.result has already been set?

Copy link
Contributor Author

@stephenchengCloud stephenchengCloud Jun 5, 2024

Choose a reason for hiding this comment

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

The caller of Result() checks if the result is none, and raises an exception if none.
As for synchronous tasks, the result returns directly from Task.Sync(). They don't need to call Result()

XSConsoleTask.py Show resolved Hide resolved
plugins-base/XSFeatureSRCreate.py Outdated Show resolved Hide resolved
@stephenchengCloud stephenchengCloud force-pushed the private/stephenche/CA-388527 branch 2 times, most recently from 86c430f to 9448b04 Compare June 6, 2024 05:45
The XSConsoleAuth set socket timout value to 15 seconds,
and it's not enough for the SR.create.
Use xenapi.Async call instead.

Signed-off-by: Stephen Cheng <[email protected]>
@stephenchengCloud
Copy link
Contributor Author

Added ProgressDialogue to show the task process.
It turns out there are only two phases of progress, one is 0%, and one is 100%. :)
Test successful case:
image
image

Test failed case:
image

@liulinC liulinC merged commit df9aa58 into xapi-project:master Jun 6, 2024
1 check passed
stephenchengCloud added a commit to stephenchengCloud/xsconsole that referenced this pull request Jun 7, 2024
The PR xapi-project#42
uses keyword-only argument which is not supported in Python2
In XS8, we still uses python2, so fix this to work both in python2
and python3

Signed-off-by: Stephen Cheng <[email protected]>
liulinC pushed a commit that referenced this pull request Jun 13, 2024
The PR #42
uses keyword-only argument which is not supported in Python2
In XS8, we still uses python2, so fix this to work both in python2
and python3

Signed-off-by: Stephen Cheng <[email protected]>
alexbrett pushed a commit to alexbrett/xsconsole-xs that referenced this pull request Jun 17, 2024
The PR xapi-project/xsconsole#42
uses keyword-only argument which is not supported in Python2
In XS8, we still uses python2, so fix this to work both in python2
and python3

Signed-off-by: Stephen Cheng <[email protected]>
rosslagerwall pushed a commit that referenced this pull request Jun 18, 2024
The PR #42
uses keyword-only argument which is not supported in Python2
In XS8, we still uses python2, so fix this to work both in python2
and python3

Signed-off-by: Stephen Cheng <[email protected]>
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.

4 participants