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

iscsi: allow for multipath setup #4067

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smitterl
Copy link
Contributor

Some tests need to simulate a multipath setup.
For this add a new parameter. If it is allowed to create multipath the export function that creates the iscsi objects will ignore if a backstor/fileio of the given name already exists.

@smitterl
Copy link
Contributor Author

Tested manually:

>>> params_1 = {'emulated_image': '/var/tmp/em1', 'target': 'iqn.2025-02.com.virttest:device.em1.target', 'image_size': '1G', 'portal_ip': '127.0.0.1', 'enable_authentication': False, 'iscsi_allow_multipath': 'yes'} 
>>> params_2 = {'emulated_image': '/var/tmp/em1', 'target': 'iqn.2025-02.com.virttest:device.em2.target', 'image_size': '1G', 'portal_ip': '127.0.0.1', 'enable_authentication': False, 'iscsi_allow_multipath': 'yes'} 
>>> _iscsi_1 = iscsi.Iscsi.create_iSCSI(params_1)
>>> _iscsi_2 = iscsi.Iscsi.create_iSCSI(params_2)
>>> _iscsi_1.login()
>>> _iscsi_2.login()

results in

# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 1]
  | | o- device.em1 ................................................................... [/var/tmp/em1 (1.0GiB) write-back activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 2]
  | o- iqn.2025-02.com.virttest:device.em1.target ........................................................................ [TPGs: 1]
  | | o- tpg1 .................................................................................................. [gen-acls, no-auth]
  | |   o- acls .......................................................................................................... [ACLs: 0]
  | |   o- luns .......................................................................................................... [LUNs: 1]
  | |   | o- lun0 ............................................................ [fileio/device.em1 (/var/tmp/em1) (default_tg_pt_gp)]
  | |   o- portals .................................................................................................... [Portals: 1]
  | |     o- 0.0.0.0:3260 ..................................................................................................... [OK]
  | o- iqn.2025-02.com.virttest:device.em2.target ........................................................................ [TPGs: 1]
  |   o- tpg1 .................................................................................................. [gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 0]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ............................................................ [fileio/device.em1 (/var/tmp/em1) (default_tg_pt_gp)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 0.0.0.0:3260 ..................................................................................................... [OK]
  o- loopback ......................................................................................................... [Targets: 0]

and it also cleans up well:

_iscsi_1.cleanup()
_iscsi_2.cleanup()
# targetcli ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 0]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 0]
  o- loopback ......................................................................................................... [Targets: 0]

output = process.run(device_cmd).stdout_text
except process.CmdError as e:
file_exists = re.match(
r".*storage object.*already exists:.*", str(e), re.DOTALL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During my test with auto case, the error message is "Storage object fileio/device.emulated-iscsi exists". So to cover all related message, maybe we can change it to file_exists = re.match( r".*storage object.*exists.*", str(e), re.DOTALL | re.IGNORECASE ) .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @meinaLi Fixed, please review again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "already" and the : after exist also need to be removed. Otherwise, the absence of these in the message will cause errors.

@smitterl smitterl force-pushed the enable_iscsi_multipath branch from b56ce48 to bb09a19 Compare March 4, 2025 07:47
@smitterl smitterl requested a review from meinaLi March 4, 2025 07:47
Some tests need to simulate a multipath setup.
For this add a new parameter. If it is allowed to create multipath
the export function that creates the iscsi objects will ignore if a
backstor/fileio of the given name already exists.

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
@smitterl smitterl force-pushed the enable_iscsi_multipath branch from bb09a19 to 4a3bbaf Compare March 4, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants