Skip to content

Commit a1eaa0e

Browse files
committed
PR fixes + remove HA comment
Signed-off-by: Ronan Abhamon <ronan.abhamon@vates.tech>
1 parent 7569314 commit a1eaa0e

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

drivers/LinstorSR.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
LINSTOR_AVAILABLE = False
3636

37+
from concurrent.futures import ThreadPoolExecutor
3738
from lock import Lock
3839
import blktap2
3940
import cleanup
@@ -49,6 +50,7 @@
4950
import SRCommand
5051
import subprocess
5152
import sys
53+
import threading
5254
import time
5355
import traceback
5456
import util
@@ -1208,26 +1210,25 @@ def _load_vdis_ex(self):
12081210
vdi_uuids.append(vdi_uuid)
12091211

12101212
# 5. Create VDIs.
1211-
import threading
1212-
12131213
all_executor_load = []
12141214

12151215
self._executor_data = threading.local()
12161216
def init_executor_thread():
12171217
class Load(object):
1218+
def __init__(self):
1219+
self._session = None
1220+
12181221
def cleanup(self):
12191222
if self._session:
1220-
self._session.xenapi._session.logout()
1221-
1222-
_session = None
1223+
self._session.xenapi.session.logout()
12231224

12241225
load = Load()
12251226

12261227
all_executor_load.append(load)
12271228

12281229
session = XenAPI.xapi_local()
12291230
session.xenapi.login_with_password('root', '', '', 'SM')
1230-
load.session = session
1231+
load._session = session
12311232
self._executor_data.session = session
12321233

12331234
linstor = LinstorVolumeManager(
@@ -1251,7 +1252,6 @@ def load_vdi(vdi_uuid):
12511252

12521253
return vdi
12531254

1254-
from concurrent.futures import ThreadPoolExecutor
12551255
try:
12561256
with ThreadPoolExecutor() as executor:
12571257
self.vdis = {vdi.uuid: vdi for vdi in executor.map(load_vdi, vdi_uuids)}
@@ -1262,7 +1262,7 @@ def load_vdi(vdi_uuid):
12621262
except Exception as e:
12631263
util.SMlog(f"Failed to clean load executor: {e}")
12641264
all_executor_load.clear()
1265-
self._executor_data = None
1265+
del self._executor_data
12661266

12671267
# 6. Update CBT status of disks either just added
12681268
# or already in XAPI.

drivers/cleanup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import os
2424
import os.path
2525
import sys
26+
import threading
2627
import time
2728
import signal
2829
import subprocess
@@ -45,6 +46,8 @@
4546
import lock
4647
import blktap2
4748
import xs_errors
49+
50+
from concurrent.futures import ThreadPoolExecutor
4851
from refcounter import RefCounter
4952
from ipc import IPCFlag
5053
from lvmanager import LVActivator
@@ -3535,26 +3538,25 @@ def handle_fail(vdi_uuid, e):
35353538
except Exception as e:
35363539
all_vdi_info[vdi_uuid] = handle_fail(vdi_uuid, e)
35373540

3538-
import threading
3539-
35403541
all_executor_load = []
35413542

35423543
executor_data = threading.local()
35433544
def init_executor_thread():
35443545
class Load(object):
3546+
def __init__(self):
3547+
self._session = None
3548+
35453549
def cleanup(self):
35463550
if self._session:
3547-
self._session.xenapi._session.logout()
3548-
3549-
_session = None
3551+
self._session.xenapi.session.logout()
35503552

35513553
load = Load()
35523554

35533555
all_executor_load.append(load)
35543556

35553557
session = XenAPI.xapi_local()
35563558
session.xenapi.login_with_password('root', '', '', 'SM')
3557-
load.session = session
3559+
load._session = session
35583560
executor_data.session = session
35593561

35603562
linstor = LinstorVolumeManager(
@@ -3575,7 +3577,6 @@ def load_info(vdi_uuid):
35753577
except Exception as e:
35763578
all_vdi_info[vdi_uuid] = handle_fail(vdi_uuid, e)
35773579

3578-
from concurrent.futures import ThreadPoolExecutor
35793580
try:
35803581
with ThreadPoolExecutor() as executor:
35813582
for info in executor.map(load_info, pending_vdi_uuids):

drivers/linstorvolumemanager.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ def get_all_volume_openers(resource_name, volume):
8484
volume = str(volume)
8585
openers = {}
8686

87-
# Make sure this call never stucks because this function can be called
88-
# during HA init and in this case we can wait forever.
89-
90-
# FIXME: Nov 29 21:54:19 r620-s1 SM: [11123] Got exception in LinstorVDI.load: ['XENAPI_PLUGIN_FAILURE', 'getVHDInfo', 'CommandException', 'Invalid argument'] (unable to get openers: signal only works in main thread)
91-
92-
# session = util.timeout_call(10, util.get_localAPI_session)
9387
session = util.get_localAPI_session()
9488

9589
hosts = session.xenapi.host.get_all_records()

0 commit comments

Comments
 (0)