Skip to content

Commit 6c9ed0b

Browse files
authored
Unity: To better handler concurrent lun attach (#355)
1 parent 71510f8 commit 6c9ed0b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

storops/unity/resource/host.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,20 @@ def _attach_with_retry(self, lun_or_snap, skip_hlu_0):
261261
# but not when attaching snap.
262262
from storops.unity.resource.lun import UnityLun as _UnityLun
263263
is_lun = isinstance(lun_or_snap, _UnityLun)
264+
265+
# If the same lun/snap attach to the same host, return the existed hlu
266+
self.update()
267+
if is_lun:
268+
host_luns = [x for x in self.host_luns if not x.snap]
269+
for host_lun in host_luns:
270+
if lun_or_snap.id == host_lun.lun.id:
271+
return host_lun.hlu
272+
else:
273+
host_snaps = [x for x in self.host_luns if x.snap]
274+
for host_snap in host_snaps:
275+
if lun_or_snap.id == host_snap.snap.id:
276+
return host_snap.hlu
277+
264278
if skip_hlu_0 and is_lun:
265279
candidate_hlu = self._random_hlu_number()
266280
lun_or_snap.attach_to(self, hlu=candidate_hlu)

0 commit comments

Comments
 (0)