The branch, master has been updated
       via  c75fbeaa961 ctdb-tests: Remove old socket wrapper state directory 
during setup
       via  97ad353a67c ctdb-tests: Actually restart if cluster doesn't become 
healthy
       via  a60e77157cb ctdb-tests: Add dump-logs command for local daemons
       via  a0a82f1b6a0 ctdb-tests: Add reqid wrapping test
       via  8663e0a64fb ctdb-daemon: Never use 0 as a client ID
      from  21dc6f8e8d8 vfs_ceph: fix cephwrap_flistxattr() debug message

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c75fbeaa96108cd4dc193ef5f4170977804e5104
Author: Martin Schwenke <[email protected]>
Date:   Sun May 12 07:52:13 2019 +1000

    ctdb-tests: Remove old socket wrapper state directory during setup
    
    Otherwise, when looping tests for a long time, nodes are unable to
    connect to each other.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13924
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Amitay Isaacs <[email protected]>
    
    Autobuild-User(master): Amitay Isaacs <[email protected]>
    Autobuild-Date(master): Mon May 13 08:42:44 UTC 2019 on sn-devel-184

commit 97ad353a67ce0232d7ca5637f1bf8886e2df1aca
Author: Martin Schwenke <[email protected]>
Date:   Fri May 10 19:22:16 2019 +1000

    ctdb-tests: Actually restart if cluster doesn't become healthy
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13924
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Amitay Isaacs <[email protected]>

commit a60e77157cb6e803ead4e93d1caeba140f955e08
Author: Martin Schwenke <[email protected]>
Date:   Sun May 5 12:31:41 2019 +1000

    ctdb-tests: Add dump-logs command for local daemons
    
    Dump a single merged log to stdout.
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Amitay Isaacs <[email protected]>

commit a0a82f1b6a0d7d94b99982579fe13291d1e6a1b0
Author: Amitay Isaacs <[email protected]>
Date:   Tue May 7 16:29:54 2019 +1000

    ctdb-tests: Add reqid wrapping test
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13930
    
    Signed-off-by: Amitay Isaacs <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>

commit 8663e0a64fbdb9ea16babbfe87d6f5d7a7b72bbd
Author: Martin Schwenke <[email protected]>
Date:   Mon May 6 15:22:49 2019 +1000

    ctdb-daemon: Never use 0 as a client ID
    
    ctdb_control_db_attach() and ctdb_control_db_detach() assume that any
    control with client ID 0 comes from another daemon and treat it
    specially.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13930
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Reviewed-by: Amitay Isaacs <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/server/ctdb_daemon.c           | 48 ++++++++++++++++++++++++++++++++++++-
 ctdb/tests/local_daemons.sh         | 28 ++++++++++++++++++++++
 ctdb/tests/scripts/integration.bash |  1 +
 ctdb/tests/src/reqid_test.c         | 16 +++++++++++++
 4 files changed, 92 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index c5733bb2592..acb40bdb8df 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1051,6 +1051,44 @@ static int ctdb_clientpid_destructor(struct 
ctdb_client_pid_list *client_pid)
        return 0;
 }
 
+static int get_new_client_id(struct reqid_context *idr,
+                            struct ctdb_client *client,
+                            uint32_t *out)
+{
+       uint32_t client_id;
+
+       client_id = reqid_new(idr, client);
+       /*
+        * Some places in the code (e.g. ctdb_control_db_attach(),
+        * ctdb_control_db_detach()) assign a special meaning to
+        * client_id 0.  The assumption is that if client_id is 0 then
+        * the control has come from another daemon.  Therefore, we
+        * should never return client_id == 0.
+        */
+       if (client_id == 0) {
+               /*
+                * Don't leak ID 0.  This is safe because the ID keeps
+                * increasing.  A test will be added to ensure that
+                * this doesn't change.
+                */
+               reqid_remove(idr, 0);
+
+               client_id = reqid_new(idr, client);
+       }
+
+       if (client_id == REQID_INVALID) {
+               return EINVAL;
+       }
+
+       if (client_id == 0) {
+               /* Every other ID must have been used and we can't use 0 */
+               reqid_remove(idr, 0);
+               return EINVAL;
+       }
+
+       *out = client_id;
+       return 0;
+}
 
 static void ctdb_accept_client(struct tevent_context *ev,
                               struct tevent_fd *fde, uint16_t flags,
@@ -1094,7 +1132,15 @@ static void ctdb_accept_client(struct tevent_context *ev,
 
        client->ctdb = ctdb;
        client->fd = fd;
-       client->client_id = reqid_new(ctdb->idr, client);
+
+       ret = get_new_client_id(ctdb->idr, client, &client->client_id);
+       if (ret != 0) {
+               DBG_ERR("Unable to get client ID (%d)\n", ret);
+               close(fd);
+               talloc_free(client);
+               return;
+       }
+
        client->pid = peer_pid;
 
        client_pid = talloc(client, struct ctdb_client_pid_list);
diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh
index 3c3897feb50..58a762b426d 100755
--- a/ctdb/tests/local_daemons.sh
+++ b/ctdb/tests/local_daemons.sh
@@ -119,6 +119,7 @@ setup_socket_wrapper ()
        ln -s "$_socket_wrapper_so" "$_so"
 
        _d="${directory}/sw"
+       rm -rf "$_d"
        mkdir -p "$_d"
 }
 
@@ -399,6 +400,31 @@ local_daemons_print_socket ()
        onnode -q "$_nodes" "${VALGRIND:-} ${_path} socket ctdbd"
 }
 
+local_daemons_dump_logs ()
+{
+       if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
+               local_daemons_generic_usage "dump-logs"
+       fi
+
+       _nodes="$1"
+       shift
+
+       onnode_common
+
+       # shellcheck disable=SC2016
+       # $CTDB_BASE must only be expanded under onnode, not in top-level shell
+       onnode -q "$_nodes" 'echo ${CTDB_BASE}/log.ctdb' |
+       while IFS='' read -r _l ; do
+               _dir=$(dirname "$_l")
+               _node=$(basename "$_dir")
+               # Add fake hostname after date and time, which are the
+               # first 2 words on each line
+               sed -e "s|^\\([^ ][^ ]* [^ ][^ ]*\\)|\\1 ${_node}|" "$_l"
+       done |
+       sort
+
+}
+
 usage ()
 {
        cat <<EOF
@@ -410,6 +436,7 @@ Commands:
   stop           Stop specified daemon(s)
   onnode         Run a command in the environment of specified daemon(s)
   print-socket   Print the Unix domain socket used by specified daemon(s)
+  dump-logs      Dump logs for specified daemon(s) to stdout
 
 All commands use <directory> for daemon configuration
 
@@ -434,5 +461,6 @@ start) local_daemons_start "$@" ;;
 stop) local_daemons_stop "$@" ;;
 onnode) local_daemons_onnode "$@" ;;
 print-socket) local_daemons_print_socket "$@" ;;
+dump-logs) local_daemons_dump_logs "$@" ;;
 *) usage ;;
 esac
diff --git a/ctdb/tests/scripts/integration.bash 
b/ctdb/tests/scripts/integration.bash
index ce5bd576b24..32a729d0249 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -520,6 +520,7 @@ ctdb_init ()
 {
     local i
     for i in $(seq 1 5) ; do
+       ctdb_stop_all >/dev/null 2>&1 || :
        ctdb_start_all || {
            echo "Start failed.  Trying again in a few seconds..."
            sleep_for 5
diff --git a/ctdb/tests/src/reqid_test.c b/ctdb/tests/src/reqid_test.c
index ec0c4a56df1..39f1fbdcc69 100644
--- a/ctdb/tests/src/reqid_test.c
+++ b/ctdb/tests/src/reqid_test.c
@@ -66,6 +66,22 @@ int main(void)
        talloc_free(reqid_ctx);
        assert(talloc_get_size(mem_ctx) == 0);
 
+       ret = reqid_init(mem_ctx, INT_MAX-1, &reqid_ctx);
+       assert(ret == 0);
+
+       reqid = reqid_new(reqid_ctx, data);
+       assert(reqid == INT_MAX);
+
+       reqid = reqid_new(reqid_ctx, data);
+       assert(reqid == 0);
+
+       reqid_remove(reqid_ctx, 0);
+
+       reqid = reqid_new(reqid_ctx, data);
+       assert(reqid == 1);
+
+       talloc_free(reqid_ctx);
+
        talloc_free(mem_ctx);
 
        return 0;


-- 
Samba Shared Repository

Reply via email to