Bug 784222

Summary: Error when creating additional LUN with add_mapped_luns=true
Product: [Fedora] Fedora Reporter: Kai Hambrecht <kai>
Component: targetcliAssignee: Andy Grover <agrover>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: agrover
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-25 18:30:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
config with two mapped LUNs - does not work none

Description Kai Hambrecht 2012-01-24 10:44:53 UTC
Created attachment 557185 [details]
config with two mapped LUNs - does not work

Description of problem:

targetcli gives an error (python traceback) when adding a second LUN to an existing target and add_mapped_luns is set to true. Happens when adding interactively in targetcli as well as when importing a previously saved config.

Version-Release number of selected component (if applicable):

targetcli-2.0rc1.fb4-1.fc16.noarch
python-rtslib-2.1.fb5-1.fc16.noarch
python-configshell-1.1.fb4-1.fc16.noarch

packages from updates-testing as referred to bug #783207

How reproducible:

Create a basic iSCSI target config with 1 LUN. Create a second storage-object and map this object to the existing target as additional LUN while add_mapped_luns (respectively auto_add_mapped_luns) is set to true.
  
Actual results:

python traceback:

/iscsi/iqn.20...b1/tpgt1/luns> create /backstores/fileio/new lun=1 add_mapped_luns=true
Successfully created LUN 1.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 990, in run_interactive
    self._cli_loop()
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 813, in _cli_loop
    self.run_cmdline(cmdline)
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 934, in run_cmdline
    self._execute_command(path, command, pparams, kparams)
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 909, in _execute_command
    result = target.execute_command(command, pparams, kparams)
  File "/usr/lib/python2.7/site-packages/targetcli/ui_node.py", line 81, in execute_command
    pparams, kparams)
  File "/usr/lib/python2.7/site-packages/configshell/node.py", line 1405, in execute_command
    result = method(*pparams, **kparams)
  File "/usr/lib/python2.7/site-packages/targetcli/ui_target.py", line 720, in ui_command_create
    % (mapped_lun, acl.node_wwn))
TypeError: %d format: a number is required, not str

Although this config works initially, it is not possible to restore this config from a savefile (e.g. from stopping/starting service targetcli.service). targetcli also fails importing a previously saved config.


Additional info:

I figured out, this happens when creating the additional LUN in the existing target (which has already one LUN mapped) and config option auto_add_mapped_luns is set to true.

Creating the additional LUN with add_mapped_luns=false and map LUN to ACL later does work. However, if auto_add_mapped_luns is true by default, Importing a saved config with more than one LUNs defined will fail.

With the previous targetcli- 2.0rc1.fb3-2.fc16, python-configshell-1.1.fb3-1.fc16 and python-rtslib-2.1.fb2-1.fc16  this error dos not occur. See attached config file. This has been created with targetcli- 2.0rc1.fb3-2 and gets successfully imported with targetcli- 2.0rc1.fb3-2, but fails with targetcli-2.0rc1.fb4-1

Comment 1 Andy Grover 2012-01-25 06:37:48 UTC
updated targetcli and python-rtslib in rawhide, please test. There may be remaining issues but it should be improved.

Comment 2 Kai Hambrecht 2012-01-25 10:10:39 UTC
packages have not been pushed to rawhide mirrors yet. So i took them from koji:
targetcli-2.0rc1.fb5-1.fc17.noarch.rpm
python-rtslib-2.1.fb7-1.fc17.noarch.rpm

works now, if you create a new config from scratch. Interactively creating an additional mapped LUN to an existing target as well as importing the new config with 2 mapped LUNs from a new savefile.

But got an error, when importing an older config saved with the previous versions 2.0rc1.fb3-2 and 2.0rc1.fb4-1 (e.g. the one attached to this bug report which was saved with 2.0rc1.fb3-2)

/> restoreconfig savefile=/tmp/config2  clear_existing=true
Configuration restored, 1 recoverable errors

As a result, the LUNs will be created in the tpgt1/luns context but did not get mapped to tpgt1/acls. So i have to manually map the LUNs to the existing ACL.

Comment 3 Andy Grover 2012-01-25 18:30:39 UTC
yes, added a mandatory value tpg_lun to mapped_lun in config file, so mapped_lun sections without it will unfortunately fail.