The branch, master has been updated via 6e4c7ae9a2e ctdb-tests: Log to stderr in statd-callout tests via ef15a34d5dd ctdb-scripts: Support script logging to stderr via 0ac9413735a ctdb-scripts: Avoid ShellCheck warning SC2162 via 59c5010b6ec ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn" via 2e2d81b92a9 ctdb-recoverd: CID 1509028 - Use of 32-bit time_t (Y2K38_SAFETY) via 862fc5770cb ctdb: Do not use egrep via 4deb178eb3e ctdb-doc: Correct bit-rotted documenation via dbbede407f7 ctdb-utils: Drop unused scsi_io.c source file from 7c0a1c1e13f s3:winbind: Set/unset the winbind_call_flow callback if log level changes
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 6e4c7ae9a2e2be4375a33e7361b8748f9307dbfe Author: Martin Schwenke <mschwe...@ddn.com> Date: Sun Jul 16 20:55:57 2023 +1000 ctdb-tests: Log to stderr in statd-callout tests Errors logged when testing statd-callout don't currently go anywhere. This is because arguments to the hacked version of script_log() are ignored. Remove the hack and configure logging to stderr. This could go in the local statd-callout.sh setup script. However, make it available for other script tests. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Wed Jul 19 09:57:37 UTC 2023 on atb-devel-224 commit ef15a34d5dd0d90e52f0fc76123077bebba949e9 Author: Martin Schwenke <mschwe...@ddn.com> Date: Sun Jul 16 20:52:54 2023 +1000 ctdb-scripts: Support script logging to stderr Logging in statd-callout tests is currently useless. This will provide a way of seeing errors in those tests. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 0ac9413735a6da449d565ff30c1e9005c739d394 Author: Martin Schwenke <mschwe...@ddn.com> Date: Sun Jul 16 20:49:57 2023 +1000 ctdb-scripts: Avoid ShellCheck warning SC2162 SC2162 read without -r will mangle backslashes. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 59c5010b6eca2f529073a348656db8f42f414365 Author: Martin Schwenke <mschwe...@ddn.com> Date: Sun Jul 16 20:47:09 2023 +1000 ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn" Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 2e2d81b92a98f97f404f536368178de3c1bfb284 Author: Martin Schwenke <mschwe...@ddn.com> Date: Wed Oct 12 09:05:25 2022 +1100 ctdb-recoverd: CID 1509028 - Use of 32-bit time_t (Y2K38_SAFETY) usecs is going to be passed as a uint32_t. There is no need to calculate it as a time_t. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 862fc5770cb672e91622fdfc01a46dc155a8c723 Author: Martin Schwenke <mschwe...@ddn.com> Date: Tue Jul 11 08:03:22 2023 +1000 ctdb: Do not use egrep On some platforms, egrep prints a deprecation warning to stderr: egrep: warning: egrep is obsolescent; using grep -E Use grep -E instead. This is nice and simple, so no use splitting this commit into 2 separate commits for each of tools and test. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 4deb178eb3e1c3236cc9a272336909305af0ad77 Author: Martin Schwenke <mschwe...@ddn.com> Date: Fri Jun 16 13:29:22 2023 +1000 ctdb-doc: Correct bit-rotted documenation Loading tunables is now done in ctdbd, so find another example for the "setup" event. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit dbbede407f79a8e8a0526f9540bb8d70c9f1c5c8 Author: Martin Schwenke <mschwe...@ddn.com> Date: Thu Mar 23 10:24:49 2023 +1100 ctdb-utils: Drop unused scsi_io.c source file It will be in the git history if we ever decide to use SCSI persistent reservations as a cluster lock. Signed-off-by: Martin Schwenke <mschwe...@ddn.com> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/config/events/README | 2 +- ctdb/config/functions | 966 ++++++++-------- ctdb/server/ctdb_recoverd.c | 2 +- ctdb/tests/CLUSTER/complex/scripts/local.bash | 2 +- .../INTEGRATION/simple/cluster.090.unreachable.sh | 2 +- ctdb/tests/UNIT/eventscripts/etc-ctdb/rc.local | 5 - ctdb/tests/UNIT/eventscripts/scripts/local.sh | 4 +- ctdb/tools/ctdb_diagnostics | 2 +- ctdb/utils/scsi_io/scsi_io.c | 1152 -------------------- 9 files changed, 495 insertions(+), 1642 deletions(-) delete mode 100644 ctdb/utils/scsi_io/scsi_io.c Changeset truncated at 500 lines: diff --git a/ctdb/config/events/README b/ctdb/config/events/README index 6ee6e6fae78..6553830326a 100644 --- a/ctdb/config/events/README +++ b/ctdb/config/events/README @@ -54,7 +54,7 @@ setup Failure of this event will cause CTDB to terminate. - Example: 00.ctdb processes tunables defined in ctdb.tunables. + Example: 11.natgw checks that it has valid configuration startup diff --git a/ctdb/config/functions b/ctdb/config/functions index 3e46fb496a3..56105aab165 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -2,9 +2,9 @@ # utility functions for ctdb event scripts -if [ -z "$CTDB_BASE" ] ; then - echo 'CTDB_BASE unset in CTDB functions file' - exit 1 +if [ -z "$CTDB_BASE" ]; then + echo 'CTDB_BASE unset in CTDB functions file' + exit 1 fi export CTDB_BASE @@ -16,24 +16,24 @@ CTDB="${CTDB:-/usr/local/bin/ctdb}" # Only (and always) override these variables in test code -if [ -z "$CTDB_SCRIPT_VARDIR" ] ; then - CTDB_SCRIPT_VARDIR="/usr/local/var/lib/ctdb/scripts" +if [ -z "$CTDB_SCRIPT_VARDIR" ]; then + CTDB_SCRIPT_VARDIR="/usr/local/var/lib/ctdb/scripts" fi -if [ -z "$CTDB_SYS_ETCDIR" ] ; then - CTDB_SYS_ETCDIR="/etc" +if [ -z "$CTDB_SYS_ETCDIR" ]; then + CTDB_SYS_ETCDIR="/etc" fi -if [ -z "$CTDB_HELPER_BINDIR" ] ; then - CTDB_HELPER_BINDIR="/usr/local/libexec/ctdb" +if [ -z "$CTDB_HELPER_BINDIR" ]; then + CTDB_HELPER_BINDIR="/usr/local/libexec/ctdb" fi ####################################### # pull in a system config file, if any -load_system_config () +load_system_config() { - for _i ; do + for _i; do if [ -f "${CTDB_SYS_ETCDIR}/sysconfig/${_i}" ]; then . "${CTDB_SYS_ETCDIR}/sysconfig/${_i}" @@ -48,11 +48,11 @@ load_system_config () # load_script_options [ component script ] # script is an event script name relative to a component # component is currently ignored -load_script_options () +load_script_options() { - if [ $# -eq 2 ] ; then + if [ $# -eq 2 ]; then _script="$2" - elif [ $# -eq 0 ] ; then + elif [ $# -eq 0 ]; then _script="" else die "usage: load_script_options [ component script ]" @@ -60,92 +60,100 @@ load_script_options () _options="${CTDB_BASE}/script.options" - if [ -r "$_options" ] ; then + if [ -r "$_options" ]; then . "$_options" fi - if [ -n "$_script" ] ; then + if [ -n "$_script" ]; then _s="${CTDB_BASE}/events/legacy/${_script}" else _s="${0%.script}" fi _options="${_s}.options" - if [ -r "$_options" ] ; then + if [ -r "$_options" ]; then . "$_options" fi } ############################################################## -die () +die() { - _msg="$1" - _rc="${2:-1}" + _msg="$1" + _rc="${2:-1}" - echo "$_msg" >&2 - exit "$_rc" + echo "$_msg" >&2 + exit "$_rc" } # Log given message or stdin to either syslog or a CTDB log file # $1 is the tag passed to logger if syslog is in use. -script_log () -{ - _tag="$1" ; shift - - case "$CTDB_LOGGING" in - file:*|"") - if [ -n "$CTDB_LOGGING" ] ; then - _file="${CTDB_LOGGING#file:}" - else - _file="/usr/local/var/log/log.ctdb" - fi - { +script_log() +{ + _tag="$1" + shift + + case "$CTDB_LOGGING" in + file:) if [ -n "$*" ] ; then - echo "$*" + echo "$*" + else + cat + fi >&2 + ;; + file:* | "") + if [ -n "$CTDB_LOGGING" ]; then + _file="${CTDB_LOGGING#file:}" else - cat + _file="/usr/local/var/log/log.ctdb" fi - } >>"$_file" - ;; + { + if [ -n "$*" ]; then + echo "$*" + else + cat + fi + } >>"$_file" + ;; *) - # Handle all syslog:* variants here too. There's no tool to do - # the lossy things, so just use logger. - logger -t "ctdbd: ${_tag}" "$@" - ;; - esac + # Handle all syslog:* variants here too. There's no tool to do + # the lossy things, so just use logger. + logger -t "ctdbd: ${_tag}" "$@" + ;; + esac } # When things are run in the background in an eventscript then logging # output might get lost. This is the "solution". :-) -background_with_logging () +background_with_logging() { - ( - "$@" 2>&1 </dev/null | - script_log "${script_name}&" - )& + ( + "$@" 2>&1 </dev/null | + script_log "${script_name}&" + ) & - return 0 + return 0 } ############################################################## # check number of args for different events -ctdb_check_args () +ctdb_check_args() { - case "$1" in - takeip|releaseip) - if [ $# != 4 ]; then - echo "ERROR: must supply interface, IP and maskbits" - exit 1 - fi - ;; + case "$1" in + takeip | releaseip) + if [ $# != 4 ]; then + echo "ERROR: must supply interface, IP and maskbits" + exit 1 + fi + ;; updateip) - if [ $# != 5 ]; then - echo "ERROR: must supply old interface, new interface, IP and maskbits" - exit 1 - fi - ;; - esac + if [ $# != 5 ]; then + echo "ERROR: must supply old interface, new interface, IP and maskbits" + exit 1 + fi + ;; + esac } ############################################################## @@ -153,7 +161,7 @@ ctdb_check_args () detect_init_style() { # only do detection if not already set: - if [ -n "$CTDB_INIT_STYLE" ] ; then + if [ -n "$CTDB_INIT_STYLE" ]; then return fi @@ -170,100 +178,100 @@ detect_init_style() # simulate /sbin/service on platforms that don't have it # _service() makes it easier to hook the service() function for # testing. -_service () +_service() { - _service_name="$1" - _op="$2" - - # do nothing, when no service was specified - [ -z "$_service_name" ] && return - - if [ -x /sbin/service ]; then - $_nice /sbin/service "$_service_name" "$_op" - elif [ -x /usr/sbin/service ]; then - $_nice /usr/sbin/service "$_service_name" "$_op" - elif [ -x /bin/systemctl ]; then - $_nice /bin/systemctl "$_op" "$_service_name" - elif [ -x "${CTDB_SYS_ETCDIR}/init.d/${_service_name}" ]; then - $_nice "${CTDB_SYS_ETCDIR}/init.d/${_service_name}" "$_op" - elif [ -x "${CTDB_SYS_ETCDIR}/rc.d/init.d/${_service_name}" ]; then - $_nice "${CTDB_SYS_ETCDIR}/rc.d/init.d/${_service_name}" "$_op" - fi + _service_name="$1" + _op="$2" + + # do nothing, when no service was specified + [ -z "$_service_name" ] && return + + if [ -x /sbin/service ]; then + $_nice /sbin/service "$_service_name" "$_op" + elif [ -x /usr/sbin/service ]; then + $_nice /usr/sbin/service "$_service_name" "$_op" + elif [ -x /bin/systemctl ]; then + $_nice /bin/systemctl "$_op" "$_service_name" + elif [ -x "${CTDB_SYS_ETCDIR}/init.d/${_service_name}" ]; then + $_nice "${CTDB_SYS_ETCDIR}/init.d/${_service_name}" "$_op" + elif [ -x "${CTDB_SYS_ETCDIR}/rc.d/init.d/${_service_name}" ]; then + $_nice "${CTDB_SYS_ETCDIR}/rc.d/init.d/${_service_name}" "$_op" + fi } service() { - _nice="" - _service "$@" + _nice="" + _service "$@" } ###################################################### # simulate /sbin/service (niced) on platforms that don't have it nice_service() { - _nice="nice" - _service "$@" + _nice="nice" + _service "$@" } ###################################################### # Cached retrieval of PNN from local node. This never changes so why # open a client connection to the server each time this is needed? -ctdb_get_pnn () +ctdb_get_pnn() { - _pnn_file="${CTDB_SCRIPT_VARDIR}/my-pnn" - if [ ! -f "$_pnn_file" ] ; then - $CTDB pnn >"$_pnn_file" - fi + _pnn_file="${CTDB_SCRIPT_VARDIR}/my-pnn" + if [ ! -f "$_pnn_file" ]; then + $CTDB pnn >"$_pnn_file" + fi - cat "$_pnn_file" + cat "$_pnn_file" } # Cached retrieval of private IP address from local node. This never # changes. -ctdb_get_ip_address () +ctdb_get_ip_address() { - _ip_addr_file="${CTDB_SCRIPT_VARDIR}/my-ip-address" - if [ ! -f "$_ip_addr_file" ] ; then - $CTDB -X nodestatus | - awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file" - fi + _ip_addr_file="${CTDB_SCRIPT_VARDIR}/my-ip-address" + if [ ! -f "$_ip_addr_file" ]; then + $CTDB -X nodestatus | + awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file" + fi - cat "$_ip_addr_file" + cat "$_ip_addr_file" } # Cached retrieval of database options for use by event scripts. # # If the variables are already set then they should not be overwritten # - this should only happen during event script testing. -ctdb_get_db_options () +ctdb_get_db_options() { _db_opts_file="${CTDB_SCRIPT_VARDIR}/db_options.cache" - if [ ! -f "$_db_opts_file" ] ; then + if [ ! -f "$_db_opts_file" ]; then { ctdb_translate_option "database" \ - "volatile database directory" \ - "CTDB_DBDIR" + "volatile database directory" \ + "CTDB_DBDIR" ctdb_translate_option "database" \ - "persistent database directory" \ - "CTDB_DBDIR_PERSISTENT" + "persistent database directory" \ + "CTDB_DBDIR_PERSISTENT" ctdb_translate_option "database" \ - "state database directory" \ - "CTDB_DBDIR_STATE" + "state database directory" \ + "CTDB_DBDIR_STATE" } >"$_db_opts_file" fi . "$_db_opts_file" } -ctdb_translate_option () +ctdb_translate_option() { _section="$1" _opt="$2" _variable="$3" # ctdb-config already prints an error if something goes wrong - _t=$("${CTDB_HELPER_BINDIR}/ctdb-config" get "$_section" "$_opt") || \ + _t=$("${CTDB_HELPER_BINDIR}/ctdb-config" get "$_section" "$_opt") || exit $? echo "${_variable}=\"${_t}\"" } @@ -272,51 +280,51 @@ ctdb_translate_option () # wrapper around /proc/ settings to allow them to be hooked # for testing # 1st arg is relative path under /proc/, 2nd arg is value to set -set_proc () +set_proc() { - echo "$2" >"/proc/$1" + echo "$2" >"/proc/$1" } -set_proc_maybe () +set_proc_maybe() { - if [ -w "/proc/$1" ] ; then - set_proc "$1" "$2" - fi + if [ -w "/proc/$1" ]; then + set_proc "$1" "$2" + fi } ###################################################### # wrapper around getting file contents from /proc/ to allow # this to be hooked for testing # 1st arg is relative path under /proc/ -get_proc () +get_proc() { - cat "/proc/$1" + cat "/proc/$1" } ###################################################### # Print up to $_max kernel stack traces for processes named $_program -program_stack_traces () +program_stack_traces() { - _prog="$1" - _max="${2:-1}" - - _count=1 - for _pid in $(pidof "$_prog") ; do - [ "$_count" -le "$_max" ] || break - - # Do this first to avoid racing with process exit - _stack=$(get_proc "${_pid}/stack" 2>/dev/null) - if [ -n "$_stack" ] ; then - echo "Stack trace for ${_prog}[${_pid}]:" - echo "$_stack" - _count=$((_count + 1)) - fi - done + _prog="$1" + _max="${2:-1}" + + _count=1 + for _pid in $(pidof "$_prog"); do + [ "$_count" -le "$_max" ] || break + + # Do this first to avoid racing with process exit + _stack=$(get_proc "${_pid}/stack" 2>/dev/null) + if [ -n "$_stack" ]; then + echo "Stack trace for ${_prog}[${_pid}]:" + echo "$_stack" + _count=$((_count + 1)) + fi + done } ###################################################### # Ensure $service_name is set -assert_service_name () +assert_service_name() { # service_name is set by the event script # shellcheck disable=SC2154 @@ -330,15 +338,16 @@ assert_service_name () ###################################################### ctdb_check_directories_probe() { - while IFS="" read d ; do - case "$d" in - *%*) - continue - ;; - *) - [ -d "${d}/." ] || return 1 - esac - done + while IFS="" read -r d; do + case "$d" in + *%*) + continue + ;; + *) + [ -d "${d}/." ] || return 1 + ;; + esac + done } ###################################################### @@ -347,10 +356,10 @@ ctdb_check_directories_probe() ###################################################### ctdb_check_directories() { - ctdb_check_directories_probe || { - echo "ERROR: $service_name directory \"$d\" not available" - exit 1 - } + ctdb_check_directories_probe || { + echo "ERROR: $service_name directory \"$d\" not available" + exit 1 + } } -- Samba Shared Repository