Skip to content

Commit 7fa711a

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

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
@@ -3516,26 +3519,25 @@ def handle_fail(vdi_uuid, e):
35163519
except Exception as e:
35173520
all_vdi_info[vdi_uuid] = handle_fail(vdi_uuid, e)
35183521

3519-
import threading
3520-
35213522
all_executor_load = []
35223523

35233524
executor_data = threading.local()
35243525
def init_executor_thread():
35253526
class Load(object):
3527+
def __init__(self):
3528+
self._session = None
3529+
35263530
def cleanup(self):
35273531
if self._session:
3528-
self._session.xenapi._session.logout()
3529-
3530-
_session = None
3532+
self._session.xenapi.session.logout()
35313533

35323534
load = Load()
35333535

35343536
all_executor_load.append(load)
35353537

35363538
session = XenAPI.xapi_local()
35373539
session.xenapi.login_with_password('root', '', '', 'SM')
3538-
load.session = session
3540+
load._session = session
35393541
executor_data.session = session
35403542

35413543
linstor = LinstorVolumeManager(
@@ -3556,7 +3558,6 @@ def load_info(vdi_uuid):
35563558
except Exception as e:
35573559
all_vdi_info[vdi_uuid] = handle_fail(vdi_uuid, e)
35583560

3559-
from concurrent.futures import ThreadPoolExecutor
35603561
try:
35613562
with ThreadPoolExecutor() as executor:
35623563
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)