| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
We fixed it earlier with commit 6e4f39357a90a914d11bac21cc2d2b52c07c213d
but that fixes the issue when someone run the targetclid with systemd
only.
If we don't use targetclid.socket and want to run `targetclid` from
command line, then socket.bind() will create the file with default
permissions.
Hence its good if we can guard the permissions right at the time of .bind()
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
happen to see yet another issue after we switch to stringIO/bytesIO:
$ targetcli ls
'unicode' does not have the buffer interface
After which I felt like dealing with StringIO/BytesIO is like a
wild goose chase and we are after all attempting to deal with python
incompatible apis.
Technically speaking, the rtslib and configshell libraries are expecting a
string IO stream, but then for python2 with ByteIO() we are passing a
bytestream, and stringIO() is behaving a bit different in python2 than
expected as explained in my previous patch.
Lets simply switch to temporary file in the most secure manner possible,
opening files in string mode will assure the compatibility across the platforms.
At the end we wish to have a consistent behaviour across all python versions.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We all know the way python3 handles strings is a bit different.
$ python2
Python 2.7.16 (default, Apr 30 2019, 15:54:43)
[GCC 9.0.1 20190312 (Red Hat 9.0.1-0.10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> s=io.BytesIO()
>>> s.write('hello')
5L
>>> s.getvalue()
'hello'
>>> s=io.StringIO()
>>> s.write('hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unicode argument expected, got 'str'
>>> s.write(u'hello')
5L
>>> s.getvalue()
u'hello'
>>>
$ python3
Python 3.6.8 (default, Dec 5 2019, 15:45:45)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> s=io.BytesIO()
>>> s.write('hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
>>> s.write(b'hello')
5
>>> s.getvalue()
b'hello'
>>> s=io.StringIO()
>>> s.write('hello')
5
>>> s.getvalue()
'hello'
>>>
The way Python2 and Python3 handles String and Bytes IO is different.
* In Python2 BytesIO() accepts text format syntax, and StringIO() expects unicodes
* While in Python3 StringIO() accepts text format syntax, and BytesIO() expects bytes like objects
I think the compatibility of using both the IO streams with python2 and python3 is compromised.
Hence this patch, uses BytesIO() and StringIO() based on python version.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
| |
We need to open a byte IO stream because we are actually dealing with
binary data in memory.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
-------
Noticing inconsistency with prefs when switching between cli mode and
daemon mode
Solution:
-------
Makesure to read/load the prefs on every new connection
Thanks to 'Xiubo Li <xiubli@redhat.com>' for reporting the problem
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
| |
Before, we would get a "Bad File Descriptor" message when
a signal causes closure of the socket while waiting on a
socket message.
|
| |
|
|
|
| |
Regular socket communications are fallen back to when
no systemd socket is present.
|
| |
|
|
|
|
|
| |
This allows the main loop to get an exception in its wait loop
when a signal arrives, rather than block forever. Before this,
topping the daemon required sending a KILL signal or sending one last
command, so that the loop could check the "received a signal" flag.
|
| |
|
|
|
| |
Save the error exit for unknown exits. This makes
systemd happier, since it stops us with a signal.
|
| |
|
|
|
| |
There's no need to return a zero-length string.
Before being fixed, this caused a hang when shutting down.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
We can no longer have python automatically convert
binary to/from string data, so be explicit about it.
Also, the TargetCLI __del__ method was testing for a
non-existant attribute, so close our socket if open.
|
| |
|
|
|
|
| |
The indentation was wrong, causing the daemon to only
process the last block of outout, which would only
show up with a lot of output.
|
| |
|
|
|
|
|
| |
"except Exception, e" triggers a syntax error on Python 3.7. The
correct syntax is "except Exception as e".
This patch fixes issue #142.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
-------
targetcli/rtslib cannot handle parallel requests at the moment.
Read more about this at http://bit.ly/targetcli-parallel-requests-issue
$ for i in {1..10}; do \
targetcli /backstores/fileio create ${i} /tmp/file${i} 10M& done
Created fileio 1 with size 10485760
This _Backstore already exists in configFS
This _Backstore already exists in configFS
This _Backstore already exists in configFS
This _Backstore already exists in configFS
This _Backstore already exists in configFS
Created fileio 6 with size 10485760
Created fileio 2 with size 10485760
This _Backstore already exists in configFS
Created fileio 8 with size 10485760
Created fileio 9 with size 10485760
bails-out most of the time with above errors and sometimes even crashes.
Solution:
--------
Serialize/defend the parallel requests by simply taking a wait lock at
targetcli level, so that only one request can be processed by targetcli at
any given point in time.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
Problem:
-------
Overall creation time of a block using targetcli is raising linearly as the
block count increase.
This is because of the recurring issue involving refresh(reload) at
multiple objects/places, as the LIO's configfs is deeply nested.
Earlier discussion of the problem statement with stats and graphs about delays:
http://bit.ly/targetcli-create-delay
Solution:
--------
Introduce a daemon component for targetcli[d] which will retain state of
Configshell object in memory, so that any new requests can directly use it,
instead of loading the storageObjects/targetObjects again.
Details about "how to use it ?":
-------------------------------
$ systemctl start targetclid
$ systemctl status targetclid
● targetclid.service - Targetcli daemon
Loaded: loaded (/usr/lib/systemd/system/targetclid.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-04-10 12:19:51 IST; 2h 17min ago
Main PID: 3950 (targetclid)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/targetclid.service
└─3950 /usr/bin/python /usr/bin/targetclid
Apr 10 12:19:51 localhost.localdomain systemd[1]: Started Targetcli daemon.
$ targetcli help
Usage: /usr/bin/targetcli [--version|--help|CMD|--tcp]
--version Print version
--help Print this information
CMD Run targetcli shell command and exit
<nothing> Enter configuration shell
--tcp CMD Pass targetcli command to targetclid
--tcp <nothing> Enter multi-line command mode for targetclid
See man page for more information.
One line command usage:
----------------------
$ targetcli --tcp CMD
Eg:
$ targetcli --tcp pwd
/
Multiple line commands usage:
----------------------------
$ targetcli --tcp
CMD1
CMD2
.
.
CMDN
exit
Eg:
$ targetcli --tcp
^Tab
/ backstores/ iscsi/ loopback/ vhost/ xen-pvscsi/ cd
clearconfig exit get help ls pwd refresh
restoreconfig saveconfig set status
pwd
get global logfile
get global auto_save_on_exit
/ saveconfig
exit
output follows:
/
logfile=/var/log/gluster-block/gluster-block-configshell.log
auto_save_on_exit=false
Configuration saved to /etc/target/saveconfig.json
Stats with and without changes:
------------------------------
Running simple 'pwd' command after creating 1000 blocks on a node:
Without this change:
$ time targetcli pwd
/
real 0m8.963s
user 0m7.775s
sys 0m1.103s
with daemonize changes:
$ time targetcli --tcp "pwd"
/
real 0m0.126s
user 0m0.099s
sys 0m0.024s
Thanks to Maurizio for hangingout with me for all the discussions involved.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|