1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

1001 Commits

Author SHA1 Message Date
Martin Schwenke
1d2d0c34fc ctdb-scripts: Strengthen check to see if ctdbd is running
Don't just rely on the process existing.  It must be called "ctdbd".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Oct 14 11:54:40 CEST 2016 on sn-devel-144
2016-10-14 11:54:40 +02:00
Martin Schwenke
b832049116 ctdb-scripts: Drop backward compatibility from ctdbd_is_running()
The PID file has been used since CTDB 2.3.  Assume that anyone
upgrading from an older version does a clean shutdown, upgrades CTDB
and then does a clean start (as opposed to upgrade CTDB and then
restart).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2016-10-13 14:25:09 +02:00
Martin Schwenke
56d526c6ea ctdb-scripts: ctdbd_wrapper should never remove the PID file
kill_ctdbd() kills the daemon and then removes the PID file.  This is
racy because a new daemon could write a new PID file in between the
kill and the removal.  Reversing these steps would be an improvement.

However, none of the places where kill_ctdbd() is called is a safe
place to remove the PID file.  There is always a chance that a new
daemon could start, write a new PID file and then kill_ctdbd() could
remove the new PID file.

ctdbd is able to overwrite a stale PID file by checking to see if it
is locked.

Therefore, entirely drop removal of the PID file from ctdbd_wrapper.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12287

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2016-10-13 14:25:09 +02:00
Martin Schwenke
72e415be4c ctdb-scripts: Dump stack traces of smbd processes after shutdown
If any processes remain then they may be stuck in D state and this
might tell us why.

Update tests: tweak pidof stub, add support for smbd stack traces and
add some new tests for the shutdown event.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Oct 10 12:54:24 CEST 2016 on sn-devel-144
2016-10-10 12:54:24 +02:00
Martin Schwenke
35dcaadc8e ctdb-packaging: Fix systemd network dependency
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ says:

  network.target has very little meaning during start-up. [...]
  Whether any network interfaces are already configured when it is
  reached is undefined. [...]

  network-online.target is a target that actively waits until the
  ne[t]work is "up",

CTDB expects to be able to bind a socket to a node address and expects
interfaces for public IP addresses to exist.  CTDB also doesn't expect
time to jump, so also wait until time is synchronised.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12255

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Steve French <sfrench@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Tested-by: Steve French <sfrench@samba.org>
2016-09-14 08:39:28 +02:00
Martin Schwenke
c730f0b337 ctdb-scripts: Optimise tickle_tcp_connections()
Pipe the connections to "ctdb tickle" on stdin to avoid having to fork
so many "ctdb tickle" processes.  This maintains the current level of
verbosity at the price of some extra memory usage.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Sep  8 10:45:42 CEST 2016 on sn-devel-144
2016-09-08 10:45:42 +02:00
Martin Schwenke
30c56a0c80 ctdb-scripts: Optimise update_tickles()
Use addtickle and deltickle with stdin.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-09-08 06:57:21 +02:00
Martin Schwenke
162857eff1 ctdb-scripts: Add early exit for redundant updateip
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-08-17 23:00:26 +02:00
Amitay Isaacs
3fafe48027 ctdb-packaging: Move ctdb configuration to ctdbd.conf
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-07-28 05:00:18 +02:00
Martin Schwenke
c3c106e41f ctdb-tools: Simplify "ctdb pnn" output format
Just print the PNN.

Update dependent code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-25 21:29:46 +02:00
Martin Schwenke
8bd2c55f98 ctdb-scripts: Avoid chellcheck warning SC2012 (ls for file list)
SC2012: Use find instead of ls to better handle non-alphanumeric filenames.

Make this cope better with unexpected whitespace.

Unfortunately, this results in shellcheck warning:

  SC2035: Use ./*.tdb.* so names with dashes won't become options.

No!  Then stat(1) will print ./file.tdb.X.  We want the basenames and
we know the filenames don't start with dashes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:27 +02:00
Martin Schwenke
52b43d73e9 ctdb-scripts: Avoid shellcheck warning SC2012 (ls for file list)
SC2012: Use find instead of ls to better handle non-alphanumeric filenames.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:27 +02:00
Martin Schwenke
5e9aa57c05 ctdb-scripts: Avoid shellcheck warning SC2038 (find without -print0)
SC2038: Use -print0/-0 or -exec + to allow for non-alphanumeric filenames.

The suggested options aren't POSIX-compliant.  This is more portable.

Base filenames can't have whitespace so rework to avoid problems with
whitespace in directory name.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:27 +02:00
Martin Schwenke
d138cb8062 ctdb-scripts: Avoid shellcheck warning SC2039 (non-portable ulimit options)
SC2039: In POSIX sh, ulimit -c/-n is not supported.

Have shellcheck suppress the warnings.  If -n is not supported then
don't set CTDB_MAX_OPEN_FILES.  If packaging for a platform where -c
is not supported then remove this code and associated documentation.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:27 +02:00
Martin Schwenke
e96c122790 ctdb-scripts: Avoid shellcheck warning SC2039 (test -nt operator)
SC2039: In POSIX sh, -nt is not supported.

This script is specific to the Linux NFS implementation.  The -nt
operator is well supported in Linux shells (e.g. dash, bash, ksh).
The alternatives (e.g. using stat(1)) would result in less readable
code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
524eac9234 ctdb-scripts: Avoid shellcheck warning SC2094 (read/write same file)
SC2094: Make sure not to read and write the same file in the same pipeline.

The semantics here are unclear, so use a separate flock file in each
case for clarity.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
d7f3b1977f ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n)
SC2039: In POSIX sh, echo flags are not supported.

echo -n is well supported but the changes are simple.

Improve some logic, replace some instances with printf.  Who knew
printf was in POSIX?

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
f43df8f0e9 ctdb-scripts: Avoid shellcheck warning SC2039 (type command)
SC2039: In POSIX sh, 'type' is not supported.

type is commonly supported and is more portable than which(1).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
b0c1dbfb8f ctdb-scripts: Avoid shellcheck warning SC2015 (A && B || C)
SC2015: Note that A && B || C is not if-then-else. C may run when A is
true.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
987fd078d2 ctdb-scripts: Avoid shellcheck warnings SC2119, SC2120 (function arguments)
SC2119: Use FUNC "$@" if function's $1 should meanscript's $1.
SC2120: FUNC references arguments, but none are ever passed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
77341f61ba ctdb-scripts: Avoid shellcheck warning SC2002 (useless cat)
SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
fc858a13e7 ctdb-scripts: Avoid shellcheck warning SC2017 (arithmetic precision)
SC2017: Increase precision by replacing a/b*c with a*c/b.

This code intentionally rounds to an even value.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
0ca00267cd ctdb-scripts: Avoid shellcheck warning SC1004 (backslash in quotes)
SC1004: You don't break lines with \ in single quotes, it results in
literal backslash-linefeed.

These don't hurt, since awk can cope with the continuations.  However,
they don't add anything.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
b208ae73d1 ctdb-scripts: Avoid shellcheck warning SC2154 (unassigned variables)
SC2154: VAR is referenced but not assigned.

Change ctdb_setup_service_state_dir(), ctdb_get_pnn() and
ctdb_get_ip_address() to print the value so it can be assigned to a
variable.  The performance gain from avoiding the sub-shells when
calling these functions is close to zero.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
9255d645f3 ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting)
SC2046: Quote this to prevent word splitting.
SC2086: Double quote to prevent globbing and word splitting.

Add some quoting where it makes sense.  Use shellcheck directives for
false-positives.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
f6c25a455a ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables)
SC2034: VAR appears unused. Verify it or export it.

Drop some variables that are unnecessarily used.  Use shellcheck
directive for false-positives.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
13b3c6af64 ctdb-scripts: Avoid shellcheck warning SC2004 ($ in arithmetic)
SC2004: $/${} is unnecessary on arithmetic variables.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
efc9af2634 ctdb-scripts: Avoid shellcheck warnings SC2030, SC2031 (subshell variables)
SC2030: Modification of VAR is local (to subshell caused by (..) group).
SC2031: VAR was modified in a subshell. That change might be lost.

Fix a related, incorrect comment.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
0ea90f6170 ctdb-scripts: Avoid shellcheck warning SC2016 ($ in single quotes)
SC2016: Expressions don't expand in single quotes, use double quotes for that.

Error messages are now arguably more readable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:26 +02:00
Martin Schwenke
113529f05e ctdb-scripts: Drop function ctdb_check_counter()
It is no longer used and adds needless complexity.

As a side-effect, the functions file can now be parsed by shellcheck.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
770fe1ff37 ctdb-scripts: Drop use of ctdb_check_counter from vsftpd event script
This makes the logic more obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
0825eff3e3 ctdb-scripts: Drop use of ctdb_check_counter from reclock event script
This makes the logic more obvious.

Fix the (probably) accidental fall-through to the regular monitor
failure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
92d0d4489e ctdb-scripts: Drop use of ctdb_check_counter from httpd event script
This makes the logic more obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
fc53256c3f ctdb-scripts: Drop use of service_tcp_ports
This makes the logic more obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
09a7a7854e ctdb-scripts: Event script indentation and whitespace cleanups
* Re-indent case labels as per new script style

  Other indentation can be tweaked later as code changes, but the
  labels are an obvious bulk change.

* Minor whitespace fixes

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
d52409dd95 ctdb-scripts: Drop use of ctdb_standard_event_handler()
It doesn't do anything.  Add a comment to its definition to explain
why it is still there.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
91eb421690 ctdb-scripts: Fix a bug in counter checking
If there are insufficient arguments then they can't be shifted.

This function will be removed shortly.  However, it needs to work for
now as tests will be added that depend on it to work.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-21 02:24:25 +02:00
Martin Schwenke
9ec9e6f77b ctdb-scripts: Quote some variable expansions
This avoids relevant shellcheck warnings.  This is most of the
shellcheck low hanging fruit in the non-test code.  Many of the other
warnings produced by shellcheck are either false positives, are
non-trivial to fix or a fix may result in worse code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Jul  6 08:15:49 CEST 2016 on sn-devel-144
2016-07-06 08:15:49 +02:00
Martin Schwenke
85b1cbb044 ctdb-scripts: Fix incorrect variable reference
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:10 +02:00
Martin Schwenke
15ed9ad035 ctdb-scripts: Use globs instead of ls to list files
shellcheck reports that using ls is fragile.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:09 +02:00
Martin Schwenke
c7ed73a617 ctdb-scripts: Fix incorrect variable reference
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:09 +02:00
Martin Schwenke
eabeecb453 ctdb-scripts: Fix incorrect variable reference
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:09 +02:00
Martin Schwenke
f227c26178 ctdb-scripts: Update script boilerplate to avoid shellcheck warnings
* Assign the output of dirname to temporary variable to avoid word
  splitting when directory name contains whitespace

* Drop export of CTDB_BASE to avoid masking broken return value -
  functions file does the export anyway

* Quote path when including functions file

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:09 +02:00
Martin Schwenke
850863a15e ctdb-scripts: Export CTDB_BASE in functions file
This avoids having to export it in every file that includes the
functions file.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:09 +02:00
Martin Schwenke
aa5b6f6e9f ctdb-scripts: Drop optional argument to nfs_check_services()
Added so that nfs_check_services() could be run against an arbirary
directory.  However, with the function moved to the event script, this
isn't useful.  CTDB_NFS_CHECKS_DIR can be used for testing instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-07-06 04:28:09 +02:00
Amitay Isaacs
fc7e863ce7 ctdb-scripts: Add new configuration variable CTDB_NOSETSCHED
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-06-20 16:21:19 +02:00
Michael Adam
c59842610b ctdb: use properly configured ctdb in debug-hung-script.sh
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sat Jun 11 10:23:03 CEST 2016 on sn-devel-144
2016-06-11 10:23:03 +02:00
Michael Adam
80492a4f91 ctdb: use properly configured ctdb in statd-callout
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
d9a44ae4bf ctdb: use properly configured ctdb in 99.timeout
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00
Michael Adam
0b98c64646 ctdb: use properly configured ctdb in 91.lvs
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-06-11 06:20:14 +02:00