1
0
mirror of https://github.com/gluster/gluster-block.git synced 2026-02-05 21:45:39 +01:00

110 Commits

Author SHA1 Message Date
Prasanna Kumar Kalever
299589bd21 logging: clip off sensitive details in debug mode
In debug mode, we capture the exec output from targetcli, which may
contain block volume credentials, this fix will clip off those auth
details.

Fixes: CVE-2020-10762
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2020-09-30 19:02:29 +05:30
Prasanna Kumar Kalever
3e897f450c logging: avoid capturing sensitive details
Unfortunately the sensitive information is leaked in the logs,
at both gluster-blockd.log and cmd_history.log.

This patch will fix it and avoid printing the auth credentials.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2020-09-30 19:02:29 +05:30
Prasanna Kumar Kalever
5d37d1eda2 version: fix GLUSTER_BLOCK_VERSION
align GLUSTER_BLOCK_VERSION to PACKAGE_VERSION

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2020-05-13 17:06:04 +05:30
Prasanna Kumar Kalever
bdb34a4eb9 version: fall back to rpm package nvr if needed
If the version is not provided by the package itself, check if the rpm
nvr has the version string that can be used

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2020-04-20 12:01:32 +05:30
Prasanna Kumar Kalever
62473a1989 gluster-block: adopt to targetclid usage
Requires: https://github.com/open-iscsi/targetcli-fb/pull/132

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-12-16 14:16:48 +05:30
Xiubo Li
6d13813ad8 create: rename gbCreate3 to gbCreate
The gbCreate3 is not that correct here, because it will not only for
the V3, but also for the followed versions.

Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2019-11-14 14:25:41 +05:30
Prasanna Kumar Kalever
d8fb2f2fa8 create: add tcmur_cmd_time_out option support
Set the tcmur_cmd_time_out=43s as default, which is larger than
each IO's timeout value(default is 30s) in the client/initiator side,
and at the same time it will be larger than 42s, the Gluster ping
timeout.

Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2019-11-14 14:25:41 +05:30
Prasanna Kumar Kalever
ec14ce741b version.h: define few macros for simplifying
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-10-17 13:44:36 +05:30
Prasanna Kumar Kalever
019925d297 reload: dependencies version check
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-10-17 13:44:36 +05:30
Prasanna Kumar Kalever
2863af468d reload: add capabilities
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-10-17 13:44:36 +05:30
Prasanna Kumar Kalever
70165bde45 reload: add ability to reload a single block volume
Problem:
-------
Right now, if any block volume is failed to load as part of service bringup
or node reboot, may be because of an issue from the backend, then there is
no way to reload that single block volume, we need to reload/restart all the\
block volumes present in the node just to load one block volume, this interrupts
ongoing  I/O (via this path) for all the volumes hosted within the node.

Solution:
--------
Add ability to reload a single block volume without touching other block volumes
in the node.

$ gluster-block help
usage:
  gluster-block [timeout <seconds>] <command> <volname[/blockname]> [<args>] [--json*]

commands:
[...]
  reload <volname/blockname>
        reload a block device.
[...]

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-10-17 13:44:36 +05:30
Prasanna Kumar Kalever
3b72a6a7c2 fix covery issues reported on 0.5dev (master)
* Null pointer dereferences
* thread dead lock
* Error handling

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-07-26 13:44:57 +05:30
Prasanna Kumar Kalever
e5e686b700 cleanup: remove unsupported code
Previously we had code which allows passing more than HA number of hosts to the
create command. But the future was incomplete and this code was left dead.

This PR removes it all, may be once we have self-healing, this sort of  feature
addition becomes more easy.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-07-22 14:54:42 +05:30
Xiubo Li
34b65eaab1 create: check the StorageObject's existence before creating
This will fix the following issues:

1, When the StorageObject creation failed the iqn will still be
created and won't be deleted in case of:

When creating BVs with the same NAME, the second time it will
fail duing to the targetcli cache db only allows one [user/$NAME]
exist, and then fails it leaving the IQN not deleted correctly.

That means there will be two different IQNs both mapped to the
same StorageObject.

2, For the case above we will also find that after the second
creation failing in the /etc/target/saveconfig.json there will be
one StorageObject with the two Targets.

In theory, there should be one StorageObject with only 1 Target.

This patch will check all the StorageObjects in saveconfig.json
before creating, if there already has one StorageObject with the
same NAME requested, it will fail directly.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-17 13:26:54 +05:30
Xiubo Li
873ac1ee83 MACROs: switch all the local vars to _*_
This will avoid something like the following odd case:

LOG("mgmt", GB_LOG_INFO, "tmp=%s", tmp);

It will always give us:

INFO: tmp=mgmt [at block_svc_routines.c+4394 :<block_create_common>]

This is because the tmp dups to the "char *tmp" in the LOG
macro.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-17 13:26:54 +05:30
Xiubo Li
18c421a736 validation: we need to know the raw error from targetcli
The old code has covered the raw errors from targetcli command, but
some of the raw errors will be very useful to get the root cause of
some bugs.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-17 13:26:54 +05:30
Xiubo Li
698dbaced0 blksize: add hw block size setting support
This will still need to depend the taregetcli's saveconfig support,
the rtslib PR is open-iscsi/rtslib-fb#150.

When creating the BV with the 'block-size <SIZE>' option:

In case all the ha nodes have supported the rtslib-fb#150:
1) if local node support the block-size, but if there is any of
   the remote nodes is not, it will fail with the cap not match error.
2) if local node does not support the block-size, no matter whether
   the remote nodes support it or not, it will always ignore the
   block-size option due to the exist bug.

In case if there is any of the ha nodes does not support rtslib-fb#150:
3) if local node support the block-size, it will always fails with the
   cap not match error.
4) if local mode does not support the block-size, no matter whether
   the remote nodes support it or not, it will ignore the block-size
   option due to the exist bug.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-07-05 12:51:02 +05:30
Xiubo Li
5581d0e27e logger: init the logDir and logfiles in initLogging
This also will fix the following warnings when running:
$ gluster-blockd --version
May 05 18:33:17 rhel3 gluster-blockd[18005]: Error opening log file: No such file or directory
May 05 18:33:17 rhel3 gluster-blockd[18005]: Logging to stderr.

This is because that all the logfiles are initialized as nil, so
opening the nil file will fail as above.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-05-30 13:44:42 +05:30
Prasanna Kumar Kalever
b8504dbbed logrotate: rename logrotate config file
Problem:
-------
Build was failing with:
[root@localhost x86_64]# rpmlint gluster-block-0.4-1.x86_64.rpm
gluster-block.x86_64: E: incoherent-logrotate-file /etc/logrotate.d/gluster-blockd
1 packages and 0 specfiles checked; 1 errors.

Solution:
--------
incoherent-logrotate-file ?

Solution:- The log file or directory name should be the same as the
package name in lower case.

Hence renaming the logrotate filename back to gluster-block

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-05-03 17:10:17 +05:30
Xiubo Li
0a2642a4ab rpms: fix compile warnings
Fix used without initialized warnings.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-05-02 19:05:14 +05:30
Prasanna Kumar Kalever
2717247d8e MSG: do not override last character from the msg
$ gluster-block create sample-test/block block.lab.green.com 1MiB
hostnames are not supported with gluster-bloc
Hint: please use ip addresses onl

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-05-02 19:00:39 +05:30
Xiubo Li
16553dd535 dyn-config: try to read it again in case the pagecache is not flushed out
Problem:
-------
We are hitting one case that when trying to change the config file and
close it, all the uncomment options will be fall back to the DEFAULT values.

Resolution:
----------
In-case if the editor (vim) follows write to a new file (.swp, .tmp ..)
and move it to actual file name later. There is a window, where we will
encounter one case that the file data is not flushed to the disk, so in
another process(here) when reading it will be empty.

Let just wait and try again.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-29 21:18:03 +05:30
Xiubo Li
9fd1fdf789 dyn-reload: slient the logs when they are the same
Problem:
-------
Currently when the new values are the same with the current ones,
we still can see the folloiwng logs:

"logDir/logLevel... now is ..."

We need to slient them.

Resolution:
----------
Just check and skip them when not any changes.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-29 21:18:03 +05:30
Xiubo Li
d3b1bb7ed5 gbConf: Use shared memory instead of from the data segment
Problems:
-------
Since we have make the cli and server routines into 2 different
processes in gluster-blockd daemon, the gbConf data will also
be have different copies. If the gbConf data is changed by the
dyn-config thread in the cli(parent) process, the new changes won't
be visible for the server(child) process.

Resolution:
----------
For the gbConf data, use the shared memory instead of the in the
data segment.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-29 21:18:03 +05:30
Xiubo Li
8d34a8bb38 spec: fix build warning
Problem:
-------
There has tons of warnings when building the rpms:

../utils/utils.h:166:25: warning: comparison with string literal results in unspecified behavior [-Waddress]
               if ((str) == "mgmt")                                     \
                         ^

gluster-block.c:463:3: warning: (near initialization for 'mobj.block_name') [-Wmissing-braces]
gluster-block.c:464:3: warning: missing braces around initializer [-Wmissing-braces]
   blockModifySizeCli msobj = {0, };
   ^

block_svc_routines.c: In function 'block_delete_cli_1_svc_st':
block_svc_routines.c:4707:37: warning: ?: using integer constants in boolean context [-Wint-in-bool-context]
   LOG("cmdlog", errCode?GB_LOG_ERROR:GB_LOG_INFO, "%s", reply->out);
../utils/utils.h:169:17: note: in definition of macro 'LOG'
             if (level <= gbConf.logLevel) {                            \
                 ^~~~~

Resolution:
----------
Use the strcmp() instead and add extra braces when initializing.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-26 15:13:33 +05:30
Xiubo Li
5b81651c6e logrotate: update the logdir path whenever it changes
When the logDir is changed via the /etc/sysconfig/gluster-blockd
config file, the logrotate should be changed too.

Fixes: #199
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-26 14:00:14 +05:30
Xiubo Li
280cdcc166 config: logDir add dyn support
This will add the dyn logDir support based the dyn-config without
restarting the gluster-blockd service.

Fixes: #199
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-26 14:00:14 +05:30
Prasanna Kumar Kalever
91ae2ca96b build: fix compile time warning
Warning seen with make:
----------------------
$ make
[...]
In file included from utils.c:15:
utils.c: In function ‘glusterBlockSetLogLevel’:
utils.h:113:27: warning: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? [-Wimplicit-function-de
claration]
                 int __ret=asprintf(ptr, ##fmt);__ret;})
                           ^~~~~~~~
utils.h:131:19: note: in expansion of macro ‘GB_ASPRINTF’
             len = GB_ASPRINTF(&buf, fmt, ##__VA_ARGS__);             \
                   ^~~~~~~~~~~
utils.c:41:5: note: in expansion of macro ‘MSG’
     MSG(stderr, "unknown LOG-LEVEL: '%d'", logLevel);
     ^~~
  CC       libgb_la-lru.lo
[...]

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-04-22 12:23:17 +05:30
Xiubo Li
6fcff951b0 logger: allow without any variable argument
If there is no any variable argument in the logger callout, it
will hit the following compile errors:

../utils/utils.h:175:34: error: expected expression before ‘,’ token
                       __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__);  \
                                  ^
gluster-blockd.c:268:5: note: in expansion of macro ‘LOG’
     LOG ("mgmt", GB_LOG_ERROR, "Test................");
     ^

More detail please see the GNU doc:
https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-18 14:12:38 +05:30
Prasanna Kumar Kalever
8599bd6fec daemon: check for dependencies version at runtime
defend on minimum targetcli, tcmu-runner versions.

Requisites:
targetcli   >= 2.1.fb46
tcmu-runner >= 1.1.3

Fixes: #76
Fixes: #118

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Tested-by: Xiubo Li <xiubli@redhat.com>
2019-04-16 11:12:49 +05:30
Niels de Vos
3ac1399c0e rpc: use modern libtirpc instead of old glibc implementation
glibc has removed the rpc functions from current releases. Instead of
relying on glibc providing these, the modern libtirpc library should be
used instead.

Change-Id: I46c979e52147abce956255de5ad16b01b5621f52
Updates: #56
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-04-15 19:32:12 +05:30
Prasanna Kumar Kalever
33d6e3d3ea LoadConfig: don't call glusterBlockSetLruCount in cli process context
Because, we don't use LruCount in CLI context.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-05 14:27:39 +05:30
Prasanna Kumar Kalever
e9fe19f44d dyn-config: log event->mask when loglevel is DEBUG or higher
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Tested-by: Xiubo Li <xiubli@redhat.com>
2019-04-05 12:08:39 +05:30
Prasanna Kumar Kalever
21f69e69db gluster-block: dump config key:value changes to respective log files
Problem:
-------
Currently cli process Loads Config on every operation in cli process
context. Hence log msgs:

DEBUG: logLevel now is TRACE [at utils.c+50:<glusterBlockSetLogLevel>]
DEBUG: glfsLruCount now is 5 [at lru.c+43:<glusterBlockSetLruCount>]

are dumped to gluster-blockd.log on every single cli operation. Apart
from the inotify triggers to Load Config.

Solution:
--------

Print the Key:Value config file parameters to respective log files based
on the process context.

That is,
- if cli process calls Load Config, then dump the logs to
gluster-block-cli.log (only DEBUG or higher level)
- if dameon process calls Load Config ( via DynConfig thread), then dump
the logs to gluster-blockd.log (in CRIT level)

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Tested-by: Xiubo Li <xiubli@redhat.com>
2019-04-05 12:08:39 +05:30
Prasanna Kumar Kalever
feb0aa1956 logs: remove '\n' in LOG() usage
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-03 18:32:11 +05:30
Xiubo Li
73dd5ba22a gluster-block: add logrotate support
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Tested-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-03 18:32:11 +05:30
Xiubo Li
ac702ac281 inotify: watch the directory not just file
Editors (such as vim, nano ..) follow different approaches to save conf file.
The two commonly followed techniques are to overwrite the existing file, or to
write to a new file (.swp, .tmp ..) and move it to actual file name later. In
the later case, the inotify fails, because the file it's been intended to watch
no longer exists, as the new file is a different file with just a same name.

To handle both the file save approaches mentioned above, it is better we watch
the directory and filter for MODIFY events.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Tested-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-03 18:32:11 +05:30
Xiubo Li
149255f9f4 logger: add CRIT loglevel support
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Tested-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-04-03 18:32:11 +05:30
Xiubo Li
209dc34416 utils: fix compile warning
passing the strlen() of the source string as the destination
length is pointless, and gcc-8 now warns about it:

utils.c: In function ‘gbStrcpy’:
utils.c:432:11: warning: ‘strncpy’ specified bound depends on the
length of the source argument [-Wstringop-overflow=]
     ret = strncpy(dest, src, n);
           ^~~~~~~~~~~~~~~~~~~~~
utils.c:427:16: note: length computed here
     size_t n = strlen(src);
                ^~~~~~~~~~~

block_svc_routines.c:184:7: warning: ‘strncat’ specified bound 1
equals source length [-Wstringop-overflow=]
       strncat(out, " ", 1);
       ^~~~~~~~~~~~~~~~~~~~
block_svc_routines.c:183:7: warning: ‘strncat’ specified bound
depends on the length of the source argument [-Wstringop-overflow=]
       strncat(out, element, strlen(element));
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-03-27 13:03:09 +05:30
Prasanna Kumar Kalever
262996608f cli: add timeout option
gluster-block (0.3)
usage:
  gluster-block [timeout <seconds>] <command> <volname[/blockname]> [<args>] [--json*]

commands:
  [...]
common cli options: (fixed formats)
  timeout <seconds>
        it is the time in seconds that cli can wait for daemon to respond.
        [default: timeout 300]
  --json*
        used to request the output result in json format [default: plain text]
        supported JSON formats: --json|--json-plain|--json-spaced|--json-pretty

Precedence of various methods to set cli timeout:
1. Options set through config file /etc/sysconfig/gluster-blockd          [Top Prio]
eg: uncommenting and adjusting key:value at /etc/sysconfig/gluster-blockd
2. Argument passed at cli
eg: timeout 900
3. Environment variable
eg: export GB_CLI_TIMEOUT=900
4. Code level defaults (300 sec)                                          [Least Prio]

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-02-20 16:17:56 +05:30
Prasanna Kumar Kalever
61e6fa82f4 cli-timeout: make rpc-timeout as configurable option
There are two rpc calls involved in the design,
Channel A: From cli process to local daemon (cli thread)
Channel B: From local daemon (cli thread) to remote daemon (remote thread)

Timeout for channel A is configurable now, using
/etc/sysconfig/gluster-blockd, by adjusting option 'GB_CLI_TIMEOUT' (in seconds)

$ cat /etc/sysconfig/gluster-blockd
GB_CLI_TIMEOUT=900

Changes to this value takes effect every time we start running/triggering new
cli command/request.

At the moment making Timeout configurable for channel B is not important, it is
hardcoded as 300 seconds in the code for now.

Some more details:
-----------------
It would have been an easy fix calling clnt_control() right after clnt_create(),
unfortunately there is a bug in glibc, which is why we had to hack the rpc
generated code instead of directly calling clnt_control(), see my very old
commit [1] which explains why we had to override (in a hacky-way) the default
generated TIMEOUT.

[1] 1dbbd7d457

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2019-01-29 19:39:06 +05:30
Amar Tumballi
0fd2ea41bd coverity: fix multiple issues (#172)
CIDs involved:
326396 - Constant variable guards deadcode
326345 - Argument cannot be negative
326355 - Infinite loop
326371 - Printf format string issue
328498 - Resource leak
328500 - Unchecked return value
326360 - Explicit null dereference

Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2019-01-03 16:24:54 +05:30
Amar Tumballi
9e38bb5968 coverity: fix pointless_string_compare issues (#171)
LOG() macro was designed to compare for specific strings, and based
on the result, log to different log files. This was done using
'strcmp()', but was using static strings. It made sense to compare
the static string directly as they resolve to same pointer while
compiling.

With this fix, was able to resolve 58 coverity issues in one shot.

Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2019-01-03 15:30:47 +05:30
Prasanna Kumar Kalever
21771ee287 loadConfig: retry opening conf-file if the initial attempt fail
In-case if your editor (vim) follows write to a new file (.swp, .tmp ..) and
move it to actual file name later. There is a window, where we encounter
'No such file or directory' error on open, because of the editors savefile
transaction.

This patch, simply give few more retries to load the conf file.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-12-10 12:58:38 +05:30
Amar Tumballi
d913aa77b3 all: fix high severity issues from coverity (#162)
CID: 326405 326394 326351 - for resource leak
CID: 326346 326389 326391 326401 326409 -
     fix string not null terminated warning

Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
2018-11-19 18:49:28 +05:30
Prasanna Kumar Kalever
471401c48a gluster-blockd: support volfile server (discovery service) setting through Env (#161)
* gluster-blockd: support volfile server setting through Env

This patch is majorly for GCS and kube use-case, where the discovery service,
whos name look like FQDN will resolve the backend volfile servers path, for
each and every block hosting volume from all the associated pods/nodes in the
cluster.

As of today gluster-blockd and tcmu-runner use localhost as volfile server
address to communicate with block hosting volumes, with this patch series we
will provide a way to set volfile server address (discovery service) of a
remote/separate gluster cluster, where the block hosting volume is running out-
side the gluster-block (daemon running) nodes.

This way, we achieve the isolation between the glusterd and gluster-blockd
daemons, and hence they both can now run in different nodes/pods.

Thanks to Amar Tumballi <amarts@redhat.com> for all the discussions
around this subject.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>

* replace: support volfile server setting through Env

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>

* genconfig: support volfile server setting through Env

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>

* config: support volfile server setting through config file

Just uncommnet below line at /etc/sysconfig/gluster-blockd and change the
value to fit discovery service name,

Ex:
> #GB_BHV_VOLSERVER="localhost"
GB_BHV_VOLSERVER="dhcpXX-YYY.lab.github.com"

followed by restart of gluster-blockd.service to take changes into effect.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2018-11-15 17:22:02 +05:30
Xiubo Li
a661484116 dyn-config: read the config file line by line instead of allocating a fixed 32K buffer
Fixes: #120

Tested-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2018-10-25 12:32:15 +05:30
Xiubo Li
4a4736103c dyn-config: fix memleak for GB_LOG_LEVEL
Tested-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2018-10-25 12:32:15 +05:30
Prasanna Kumar Kalever
fd62ac4f57 gluster-block: dump all failure msgs to stderr
Ensure:
On FAILURE dump error msg to stderr
On SUCCESS dump response to stdout

Fixes: #117
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
2018-10-24 17:22:50 +05:30
Amar Tumballi
3ab7b06534 all: fix build warnings
For global structure initialization, set only the fields
which are non-zero.

Fixes: #140
Reviewed-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-10-24 13:17:32 +05:30