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

Unity: To better handler concurrent lun attach #355

Merged
merged 1 commit into from
Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions storops/unity/resource/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ def _attach_with_retry(self, lun_or_snap, skip_hlu_0):
# but not when attaching snap.
from storops.unity.resource.lun import UnityLun as _UnityLun
is_lun = isinstance(lun_or_snap, _UnityLun)

# If the same lun/snap attach to the same host, return the existed hlu
self.update()
if is_lun:
host_luns = [x for x in self.host_luns if not x.snap]
for host_lun in host_luns:
if lun_or_snap.id == host_lun.lun.id:
return host_lun.hlu
else:
host_snaps = [x for x in self.host_luns if x.snap]
for host_snap in host_snaps:
if lun_or_snap.id == host_snap.snap.id:
return host_snap.hlu

if skip_hlu_0 and is_lun:
candidate_hlu = self._random_hlu_number()
lun_or_snap.attach_to(self, hlu=candidate_hlu)
Expand Down