Skip to content

Commit

Permalink
CA-388527 xsconsole: 'timed out' when creating an ISCSI SR
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
stephenchengCloud committed Jun 4, 2024
1 parent e6ce0f5 commit c10c58c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions XSConsoleTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, inHotOpaqueRef, inSession):
self.completed = False
self.creationTime = None
self.finishTime = None
self.result = None

def Completed(self):
return self.completed
Expand All @@ -37,6 +38,8 @@ def HandleCompletion(self, inStatus):

self.creationTime = TimeUtils.DateTimeToSecs(self.session.xenapi.task.get_created(self.hotOpaqueRef.OpaqueRef()))
self.finishTime = TimeUtils.DateTimeToSecs(self.session.xenapi.task.get_finished(self.hotOpaqueRef.OpaqueRef()))
if inStatus.startswith('success'):
self.result = self.session.xenapi.task.get_result(self.hotOpaqueRef.OpaqueRef())
if inStatus.startswith('failure'):
self.errorInfo = self.session.xenapi.task.get_error_info(self.hotOpaqueRef.OpaqueRef())

Expand All @@ -53,11 +56,7 @@ def Status(self):
return status

def Result(self):
if self.Completed():
result = self.completionStatus
else:
result= self.session.xenapi.task.get_status(self.hotOpaqueRef.OpaqueRef())
return HotOpaqueRef(result, 'any')
return self.result

def CanCancel(self):
if self.Completed():
Expand Down
10 changes: 8 additions & 2 deletions plugins-base/XSFeatureSRCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ def CommitCreate(self, inType, inDeviceConfig, inOtherConfig = None):
Layout.Inst().PopDialogue()
Layout.Inst().TransientBanner(Lang('Creating Storage Repository...'))
try:
srRef = Task.Sync(lambda x: x.xenapi.SR.create(
async_task = Task.New(lambda x: x.xenapi.Async.SR.create(
HotAccessor().local_host_ref().OpaqueRef(), # host
inDeviceConfig,
'0', # physical_size
Expand All @@ -1185,7 +1185,13 @@ def CommitCreate(self, inType, inDeviceConfig, inOtherConfig = None):
True # shared
)
)

# Wait until the task is completed
while async_task.IsPending():
time.sleep(2)

srRef = async_task.Result()
if not srRef:
async_task.RaiseIfFailed()
# Set values in other_config only if the SR.create operation hasn't already set them
for key, value in FirstValue(inOtherConfig, {}).items():
try:
Expand Down

0 comments on commit c10c58c

Please sign in to comment.