diff options
-rwxr-xr-x | tests/bugs/glusterd/bug-1293414-import-brickinfo-uuid.t | 31 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 20 |
2 files changed, 48 insertions, 3 deletions
diff --git a/tests/bugs/glusterd/bug-1293414-import-brickinfo-uuid.t b/tests/bugs/glusterd/bug-1293414-import-brickinfo-uuid.t new file mode 100755 index 00000000000..9f67e4ccfa0 --- /dev/null +++ b/tests/bugs/glusterd/bug-1293414-import-brickinfo-uuid.t @@ -0,0 +1,31 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../cluster.rc + +cleanup; + +TEST launch_cluster 4; + +TEST $CLI_1 peer probe $H2; +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count +TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 +TEST $CLI_1 volume start $V0 + + +TEST $CLI_1 peer probe $H3; +EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count + +TEST $CLI_1 peer probe $H4; +EXPECT_WITHIN $PROBE_TIMEOUT 3 peer_count + +# peers hosting bricks can't be detached +TEST ! $CLI_3 peer detach $H1 +TEST ! $CLI_3 peer detach $H2 + + +# peer not hosting bricks should be detachable +TEST $CLI_3 peer detach $H4 +EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count +cleanup; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 2e2607b6d08..f129b1cb04f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2547,6 +2547,14 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, goto out; memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.brick%d.uuid", + prefix, count, i); + ret = dict_set_dynstr_with_alloc (dict, key, + uuid_utoa(brickinfo->uuid)); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.brick%d", prefix, count, i); ret = gd_add_brick_snap_details_to_dict (dict, key, brickinfo); if (ret) @@ -3010,6 +3018,7 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, glusterd_brickinfo_t *new_brickinfo = NULL; char msg[2048] = {0}; xlator_t *this = NULL; + char *brick_uuid_str = NULL; this = THIS; GF_ASSERT (this); @@ -3067,9 +3076,14 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count, if (ret) goto out; - //peerinfo might not be added yet - (void) glusterd_resolve_brick (new_brickinfo); - ret = 0; + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.brick%d.uuid", + prefix, vol_count, brick_count); + ret = dict_get_str (peer_data, key, &brick_uuid_str); + if (ret) + goto out; + gf_uuid_parse (brick_uuid_str, new_brickinfo->uuid); + *brickinfo = new_brickinfo; out: if (msg[0]) |