From e8034a43e112e5e493747ba5b160080ae16e7e79 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 16 Jan 2017 07:24:15 +1100 Subject: [PATCH 1/2] ctdb-scripts: Fix regression when cleaning up routing table IDs Commit 0ca00267cd2620a14968961738bcd2a69b597e95 removed explicit continuations in strings for awk programs. In one case this causes a disconnect between condition and action, where an implicit continuation does not work. This results in duplicate lines in the rt_tables file. Move the opening brace for the action to make the implicit continuation work as expected. An alternative would be to revert the removal of the explicit continuations and add shellcheck tags. However, that doesn't mean that an author of future code will necessarily use explicit continuations, so the same mistake might still be make in the future. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12516 Reported-by: Barry Evans Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit f9368f8e129cb32ee30cb6501a6fe728db37e1d5) --- ctdb/config/events.d/13.per_ip_routing | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing index c6a87c9..41724bb 100755 --- a/ctdb/config/events.d/13.per_ip_routing +++ b/ctdb/config/events.d/13.per_ip_routing @@ -184,8 +184,8 @@ clean_up_table_ids () -v pre="$table_id_prefix" \ '/^#/ || !(min <= $1 && $1 <= max) && - !(index($2, pre) == 1) - { print $0 }' "$rt_tables" >"$_tmp" + !(index($2, pre) == 1) { + print $0 }' "$rt_tables" >"$_tmp" mv "$_tmp" "$rt_tables" ) 9>"$rt_tables_lock" -- 2.9.3 From aabe4004f7059700193b45ff00ac368bc7da442d Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 16 Jan 2017 11:08:51 +1100 Subject: [PATCH 2/2] ctdb-tests: Add "13.per_ip_routing shutdown" test Ensure that it doesn't mangle the rt_tables file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12516 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue Jan 17 06:02:23 CET 2017 on sn-devel-144 (cherry picked from commit eaa508b82650197a7d473a24b3362e9e9c329937) --- ctdb/tests/eventscripts/13.per_ip_routing.024.sh | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 ctdb/tests/eventscripts/13.per_ip_routing.024.sh diff --git a/ctdb/tests/eventscripts/13.per_ip_routing.024.sh b/ctdb/tests/eventscripts/13.per_ip_routing.024.sh new file mode 100755 index 0000000..7daacbb --- /dev/null +++ b/ctdb/tests/eventscripts/13.per_ip_routing.024.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "Single IP, restores original rt_tables" + +setup_ctdb +setup_ctdb_policy_routing + +create_policy_routing_config 1 default + +_rt_tables="$CTDB_SYS_ETCDIR/iproute2/rt_tables" +_rt_orig=$(mktemp --tmpdir="$EVENTSCRIPTS_TESTS_VAR_DIR") +cp "$_rt_tables" "$_rt_orig" + +ctdb_get_1_public_address | { + read dev ip bits + + ok_null + simple_test_event "takeip" $dev $ip $bits + + ok <