diff options
author | Gaurav Yadav <gyadav@redhat.com> | 2017-08-18 19:46:47 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-08-29 13:52:37 +0000 |
commit | 5b0c2b45144b620507a00df7488966abb979fd20 (patch) | |
tree | 00d3554375d1711f8d0ef57412966041f854a6fc | |
parent | 4d7f81c4ff3c42e84bfa65cf71755bc3553bc02c (diff) |
glusterd: glusterd fails to start if peers file has blank line
Problem:
On start of glusterd service, glusterd fetch data from store, while
parsing data from store if peers file consists of blank line glusterd
fails to start.
Fix:
With this fix while parsing peers file glusterd will skip blank lines
if it contains any.
>Reviewed-on: https://review.gluster.org/18066
>Tested-by: Gaurav Yadav <gyadav@redhat.com>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Prashanth Pai <ppai@redhat.com>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
>Reviewed-by: Niels de Vos <ndevos@redhat.com>
Change-Id: I53cd65a54de5f57baef292b2118b70ffb7f99388
BUG: 1486107
Signed-off-by: Gaurav Yadav <gyadav@redhat.com>
Reviewed-on: https://review.gluster.org/18124
Reviewed-by: Prashanth Pai <ppai@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-rw-r--r-- | libglusterfs/src/store.c | 4 | ||||
-rw-r--r-- | tests/bugs/glusterd/bug-1482906-peer-file-blank-line.t | 29 |
2 files changed, 33 insertions, 0 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c index 199ba2960d1..e805f20bb4c 100644 --- a/libglusterfs/src/store.c +++ b/libglusterfs/src/store.c @@ -195,6 +195,7 @@ gf_store_read_and_tokenize (FILE *file, char *str, int size, char **iter_key, GF_ASSERT (iter_val); GF_ASSERT (store_errno); +retry: temp = fgets (str, size, file); if (temp == NULL || feof (file)) { ret = -1; @@ -202,6 +203,9 @@ gf_store_read_and_tokenize (FILE *file, char *str, int size, char **iter_key, goto out; } + if (strcmp (str, "\n") == 0) + goto retry; + str_len = strlen(str); str[str_len - 1] = '\0'; /* Truncate the "\n", as fgets stores "\n" in str */ diff --git a/tests/bugs/glusterd/bug-1482906-peer-file-blank-line.t b/tests/bugs/glusterd/bug-1482906-peer-file-blank-line.t new file mode 100644 index 00000000000..967595e4dbb --- /dev/null +++ b/tests/bugs/glusterd/bug-1482906-peer-file-blank-line.t @@ -0,0 +1,29 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../cluster.rc + +#Tests for add new line in peers file +function add_new_line_to_peer_file { + UUID_NAME=$($CLI_1 peer status | grep Uuid) + PEER_ID=$(echo $UUID_NAME | cut -c 7-) + GD_WD=$($CLI_1 system getwd) + GD_WD+=/peers/ + PATH_TO_PEER_FILE=$GD_WD$PEER_ID + sed -i '1s/^/\n/gm; $s/$/\n/gm' $PATH_TO_PEER_FILE +} + +cleanup; + +TEST launch_cluster 2; + +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count + +add_new_line_to_peer_file + +TEST kill_glusterd 1 +TEST $glusterd_1 + +cleanup; |