ctdb-tools: Simplify "ctdb getreclock" output
authorMartin Schwenke <martin@meltin.net>
Tue, 5 Apr 2016 02:04:36 +0000 (12:04 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 28 Apr 2016 07:39:16 +0000 (09:39 +0200)
If the reclock is set then print it, otherwise print nothing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/doc/ctdb.1.xml
ctdb/tests/simple/35_set_reclock.sh
ctdb/tools/ctdb.c

index 12ead0064861e1173f105d67ebb4903ef446a249..cbdc5c7847f2e21c87b4d10bc3c6e64ce9eca3c2 100644 (file)
@@ -955,14 +955,14 @@ DB Statistics: locking.tdb
     <refsect2>
       <title>getreclock</title>
       <para>
-       Show the name of the recovery lock file, if any.
+       Show details of the recovery lock, if any.
       </para>
 
       <para>
        Example output:
       </para>
       <screen>
-       Reclock file:/clusterfs/.ctdb/recovery.lock
+       /clusterfs/.ctdb/recovery.lock
       </screen>
 
     </refsect2>
index 07e31855e34b580c8fbe0bacfc7ce25a34bc9818..7a515ee38b3d985b737f70d606b72db6013ac5f6 100755 (executable)
@@ -60,8 +60,8 @@ fi
 
 echo
 echo "Check that recovery lock is actually enabled..."
-t=$(echo "$out" | sed -e 's@^Reclock file:@@' | sort -u)
-if [ "$t" != "No reclock file used." ] ; then
+orig_reclock=$(echo "$out" | sort -u)
+if [ "$orig_reclock" != "" ] ; then
     echo "OK: Recovery lock is set"
 else
     echo "OOPS: Recovery lock is unset. Skipping remainder of test"
@@ -69,8 +69,7 @@ else
 fi
 
 echo
-orig_reclock=$(sed -n -e '1s@^Reclock file:@@p' <<<"$out")
-echo "Remember original recovery lock file: \"${orig_reclock}\""
+echo "Original recovery lock file: \"${orig_reclock}\""
 
 echo
 echo "Unset and test the recovery lock on all nodes..."
@@ -78,7 +77,7 @@ try_command_on_node -pq all $CTDB setreclock
 wait_until_recovered
 try_command_on_node -v -q all $CTDB getreclock
 t=$(sort -u <<<"$out")
-if [ "$t" = "No reclock file used." ] ; then
+if [ "$t" = "" ] ; then
     echo "GOOD: Recovery lock unset on all nodes"
 else
     echo "BAD: Recovery lock not unset on all nodes"
@@ -95,7 +94,7 @@ echo "Set alternative recovery lock (${alt}) and test on all nodes..."
 try_command_on_node -pq all $CTDB setreclock "$alt"
 wait_until_recovered
 try_command_on_node -v -q all $CTDB getreclock
-t=$(echo "$out" | sed -e 's@^Reclock file:@@' | sort -u)
+t=$(echo "$out" | sort -u)
 if [ "$t" = "$alt" ] ; then
     echo "GOOD: Recovery lock set on all nodes"
 else
@@ -113,7 +112,7 @@ try_command_on_node -pq all $CTDB setreclock "$orig_reclock"
 wait_until_recovered
 try_command_on_node -v all rm -vf "$alt"
 try_command_on_node -v -q all $CTDB getreclock
-t=$(echo "$out" | sed -e 's@^Reclock file:@@' | sort -u)
+t=$(echo "$out" | sort -u)
 if [ "$t" = "$orig_reclock" ] ; then
     echo "GOOD: Recovery lock restored on all nodes"
 else
index 8d1feec9f064f8f5e4a5ad57d745e11647f70fc3..58c8339a13a30675c0aa0f9798921e1f7219e74c 100644 (file)
@@ -4224,16 +4224,8 @@ static int control_getreclock(struct ctdb_context *ctdb, int argc, const char **
                DEBUG(DEBUG_ERR, ("Unable to get reclock file from node %u\n", options.pnn));
                return ret;
        } else {
-               if (options.machinereadable){
-                       if (reclock != NULL) {
-                               printm("%s", reclock);
-                       }
-               } else {
-                       if (reclock == NULL) {
-                               printf("No reclock file used.\n");
-                       } else {
-                               printf("Reclock file:%s\n", reclock);
-                       }
+               if (reclock != NULL) {
+                       printf("%s\n", reclock);
                }
        }
        return 0;