summaryrefslogtreecommitdiffstats
path: root/ctdb/config/functions
Commit message (Collapse)AuthorAgeFilesLines
...
* Eventscripts: fix typo in _ctdb_counter_common().Martin Schwenke2011-08-111-1/+1
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f57d1722b6aa082f3f826171acc57d7d796ea95c)
* Eventscripts: improve log messages in ctdb_start_stop_service().Martin Schwenke2011-08-111-2/+2
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 6da7095192fb172a06b434cfb02f4bfa6221b343)
* Eventscript functions: fix counter regression.Martin Schwenke2011-08-111-4/+4
| | | | | | | | | | d362be7d32079ac1390d67056ce107bfbca2c937 wasn't well thought out. Subsequent commits depend on ctdb_counter_init() taking an argument, so this makes those cases work. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 05a8fcfbac3da2b5843b31e0fe258255cc761190)
* Eventscript functions: ctdb_service_check-reconfigure() acts only on monitor.Martin Schwenke2011-08-111-0/+2
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit beabf506a5eb68fc50fdbf8772c1d2bb0f7951e3)
* Eventscripts: rejig the reconfigure infrastructure.Martin Schwenke2011-08-111-11/+35
| | | | | | | | | | | | | | | | | | * Add an optional service name argument to existing reconfigure functions. * User function service_reconfigure() instead of variable $service_reconfigure to specify how a service is reconfigured. * New function ctdb_service_check_reconfigure() reconfigures a service if it is flagged for reconfigure. * Remove $service_reconfigure settings from 40.vsftpd and 41.httpd - they're the defaults. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 15d4111d0761d82f57d5d4f0b1227812d14e4d7c)
* Eventscript functions: move flagging of managed services.Martin Schwenke2011-08-111-6/+8
| | | | | | | | | | | Move flagging of managed or unmanaged services into ctdb_service_start() and ctdb_service_stop(). That way services will be correctly flagged if they are started from the startup and shutdown events. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 8675744cbd90b5a5095ed6fff7b36ae82004a457)
* Eventscript function: change service_start into a function.Martin Schwenke2011-08-111-11/+28
| | | | | | | | | | | | | | | | | | | service_start is currently a variable. This makes passing arguments hard. We change it to be a function and put default definitions into the functions file. We use a convention that if a service name argument is passed to a redefined version of service_start() or service_stop() then it will act unconditionally. If no argument is passed then it can use internal logic to decide if services should really be started. This is useful when a single eventscript handles multiple services. This is a cherry-pick of ae38895 that needed to be reset mid-stream. There is still some breakage following this commit. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 86e4aefed9fd1028660c98e3ea758c2b75ffc1d8)
* Eventscript functions: add optional event name argument to fail count functions.Martin Schwenke2011-08-111-5/+6
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit b14f18649f42aab80ce0336c15ab6159f241c9af)
* Eventscript functions - optimise is_ctdb_managed_service().Martin Schwenke2011-08-111-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function generates a lot of trace when running under "set -x". This is due to the backward compatibility code. This adds 3 optimisations: 1. Before invoking the backward compatiblity code, is_ctdb_managed_service() returns early if the service is listed in $CTDB_MANAGED_SERVICES. 2. ctdb_compat_managed_service() actually now updates $CTDB_MANAGED_SERVICES instead of temporary variable $t. This means that a subsequent call to is_ctdb_managed_service() will short circuit due to optimisation (1). 3. ctdb_compat_managed_service() only adds a service to $CTDB_MANAGED_SERVICES if it is the service being checked by is_ctdb_managed_service(). This stops irrelevant services being added to $CTDB_MANAGED_SERVICES multiple times by multiple calls to is_ctdb_managed_service(). Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 758f4667c60089e09a0439c1eb74f5e426ca5e2e)
* Eventscript functions: new function ctdb_setup_service_state_dir().Martin Schwenke2011-08-091-0/+9
| | | | | | | | | | To be used by eventscripts to create a per-service directory for their own state data. $service_state_dir is set to point to the new directory. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit a273554791c2a5281aee28f8e2be0c514e14c91e)
* Eventscript functions: new functions to remember/check if service managed.Martin Schwenke2011-08-091-8/+38
| | | | | | | | This was done ad hoc and was badly named. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 9a084a121f629b2c1bcefc1e4c4a4a5cacf53987)
* Eventscripts: source a file specified by $CTDB_RC_LOCAL in functions file.Martin Schwenke2011-08-081-0/+4
| | | | | | | | | | | Another unit testing hook. This is easier than dropping files into rc.local.d/ and then removing them. The file has to be executable. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit b13ac3bdaf326a6cdfd87da9195eb9630806c418)
* Eventscript functions - use $CTDB_VARDIR instead of local $ctdb_spool_dir.Martin Schwenke2011-08-081-4/+3
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit d0c6d9b19f0dd8946f9504b0d1cf50dd21f7a592)
* Eventscripts: use set_proc() in startstop_nfs().Martin Schwenke2011-08-031-2/+2
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 5a3d5c6b1ca3682bb45104e50061871dec6e9b1d)
* Eventscripts: remove unnecessary absolute paths from external commands.Martin Schwenke2011-08-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | For eventscript unit testing it will be necessary to override external commands to allow stub implementations to be used. If absolute paths aren't used then this can be done using either a fake bin/ subdirectory or by using shell functions. This removes all of the simple cases of absolute paths. Signed-off-by: Martin Schwenke <martin@meltin.net> Conflicts: config/ctdb.init config/events.d/50.samba Keep old code but remove absolute paths. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 05851d50b0078de8bf4691442d718825adca6fe8)
* Eventscripts: new functions set_proc() and get_proc().Martin Schwenke2011-08-031-0/+18
| | | | | | | | | These provide a thin layer around writing and reading files in /proc. They can be easily replaced by stubs for unit testing. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 637f9d8af517b73c72ed8f3cc2a2661f11eb2126)
* Eventscripts: remove ctdb_wait_command() and ctdb_wait_tcp_ports() functions.Martin Schwenke2011-08-031-59/+0
| | | | | | | | These haven't been used for a long time. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f5fd361cadb3ea18d29e2d7215a7853718e48d00)
* Eventscripts: iptables() should put lock in $CTDB_VARDIR.Martin Schwenke2011-08-031-1/+1
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 3f04793f391c63b78ffb9c9851ab3f0daf3ed50a)
* Make Emacs recognise that the eventscript functions file is a shell script.Martin Schwenke2011-08-031-0/+2
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit a6dfb76cfa759f6f9409f24368111c4f85ca0fbf)
* Eventscript functions: add $CTDB_ETCDIR and hook service() functions.Martin Schwenke2011-08-031-29/+30
| | | | | | | | | | | | | | | * $CTDB_ETCDIR defaults to /etc but can be changed for testing. All hard-coded instances of /etc have been changed to $CTDB_ETCDIR. This includes references to /etc/init.d and /etc/sysconfig. * service() and nice_service() functions now call new function _service(). This makes it easier to override these functions (say, in rc.local) for testing and call most of the existing functionality using _service(). Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f43c9a7604b779bb6257ddb2bf3cbe266d496a63)
* Set $CTDB_VARDIR in the functions file.Martin Schwenke2011-08-031-0/+4
| | | | | | | | | This will be needed when eventscripts that use it are called externally. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit ebd53b66b0cc66d9d04830781886234167fc2164)
* Eventscripts: only autostart during a monitor event.Martin Schwenke2011-01-111-0/+3
| | | | | | | | | Otherwise we might short-circuit events that are run only once and actually need to do something. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit c4f9e8a43540bc049b2771e0a2d76d37b9d17331)
* Eventscripts: print a message when reconfiguring a service.Martin Schwenke2011-01-111-0/+1
| | | | | | | | | Otherwise there can be strange error messages from services stopping/starting, without any context. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 8bcf7ab164429ddc0ae530133e114f186a8146dd)
* Eventscripts: work around NFS restart failure under load.Martin Schwenke2011-01-111-3/+10
| | | | | | | | | | | | | | "service nfs restart" can fail. To stop nfsd it sends a SIGINT and nfsd might take a while to process it if the system is loaded. Starting nfsd may then fail because resources are still in use. This does some /proc magic to tell nfsd to do no more processing. It then runs service stop, kills nfsd with SIGKILL, and then runs service start. This is much less likely to fail. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit a9bf4f82852975b0b627f61ceb2d23401f630805)
* add a missing part of the import of the previous ganesha patchRonnie Sahlberg2010-12-061-0/+1
| | | | (This used to be ctdb commit 171b8855bb2feae7f7dd6a079571f3113dedd6f4)
* update autostart/stop to work for sambaRonnie Sahlberg2010-11-221-5/+4
| | | | (This used to be ctdb commit 37ab57e2adaecc3f7996ea20af45a5df0cd8be76)
* Eventscript functions - catch failures in ctdb_service_start().Martin Schwenke2010-11-181-2/+2
| | | | | | | | | | | ctdb_service_start() currently succeeds if ctdb_counter_init() succeeds. This changes it to fail when a service start fails. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit ddb73962d72d933bf0edc28be0dbb45bea7e5ef4)
* 50.samba eventscript should stop/start services when they become (un)managed.Martin Schwenke2010-11-181-5/+9
| | | | | | | | | | | | | | | | | | | | | When the value of $CTDB_MANAGES_SAMBA or $CTDB_MANAGES_WINBIND (or corresponding changes are made to $CTDB_MANAGED_VERSIONS), the associated service should be started or stopped as necessary. This add calls to ctdb_start_stop_service() to manage starting/stopping samba and winbind. An associated cleanup is made to the initial checks that one of $CTDB_MANAGES_SAMBA or $CTDB_MANAGES_WINBIND is set, replacing them with calls to is_ctdb_managed_service(). To handle the winbind cases ctdb_start_stop_service() and is_ctdb_managed_service() are updated to take an optional service name parameter. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit d98f175e8420d921a123ae9c0ce00945350b1537)
* add a new support function ctdb_check_counter_equal()Ronnie Sahlberg2010-11-171-0/+13
| | | | | | | | | update nfs to try to restart the service after 10 consecutive failures and to flag the node unhealthy after 15 add similar function to mountd (This used to be ctdb commit 1569a54bb82fc433895ed68f816cf48399ad9d40)
* Eventscripts: make loadconfig() function hookable by the test suite.Martin Schwenke2010-11-171-1/+5
| | | | | | | | | | | Rename loadconfig() to _loadconfig(). Add a new loadconfig() that simply calls _loadconfig(). This makes it easy for the test suite to override loadconfig(). Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 1d77a3adfff893b3c01b87f791e72c0d3148425c)
* 60.nfs only fails or warns after 10 consecutive nfsd/statd failures.Martin Schwenke2010-11-171-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | These failures are sometimes the result of slow restarts so we want to avoid dirtying the logs or marking a node unhealthy because of them, unless they are excessive. For these 2 cases we use the existing fail counting code but hack a temporary service_name in a subshell to allow separate fail counts. We also update ctdb_check_rpc() so that it captures the error output from rpcinfo and we add a message including the service name to the beginning. The error is printed to stdout but is also stored in ctdb_check_rpc_out to allow it to be conditionally used by the caller. This function also now returns non-zero rather than exiting on failure. Other direct rpcinfo calls are relaced by called to ctdb_check_rpc() for consistency. Option handling code for service restarts is cleaned up so that fits in 80 columns. A more informative restart messageis now used in all cases, printing the exact command being used to start a service. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 79c25fe241cf5d8f92e23d3736823ebaf4e1769d)
* try to restart NFS LOCKD if it failed to startRonnie Sahlberg2010-10-141-0/+8
| | | | (This used to be ctdb commit 2913cc93a9a172caf9e0d6675cfa4de4cc957b13)
* Dont store temporary runtime data in $CTDB_BASE/stateRonnie Sahlberg2010-09-031-7/+7
| | | | | | | | | since that will usually be /etc/ctdb/state and storing this under /etc is just wrong. Add a new variable CTDB_VARDIR that defaults to /var/ctdb and store the data there instead. (This used to be ctdb commit 516423c25afa9861d9988096efa8a4a2b12b31b1)
* NFS tickles: use addtickle/deltickle instead of shared tickle directory.Martin Schwenke2010-08-261-0/+55
| | | | | | | | | | | | | | This adds a new function update_tickles() that tracks tickles for a given port using the new ctdb addtickle/deltickle commands. This function is used in events.d/60.nfs to handle NFS tickles. events.d/61.nfstickle is removed. The /proc/sys/net/ipv4/tcp_tw_recycle setup is also moved to events.d/60.nfs. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit dca4c4ebf3c35f8db3ae208efb7a83abbf726ed6)
* On RHEL, "service nfs stop;service nfs start" and "service nfs restart"Ronnie Sahlberg2010-08-191-0/+7
| | | | | | | | | | | | | | sometimes (very rarely) fails to restart the service. Add a function to restart NFSd on SLES and RHEL-like systems. If we detect the system is unhealthy due to kNFSd not running, try to restart the service again "service nfs restart" and hope for the best. CQ1019372 (This used to be ctdb commit 25c4ce7e919f13226219f036bcffd2be76b2f06c)
* config: wrap iptables in flock to avoid concurrancy.Rusty Russell2010-07-151-0/+6
| | | | | | | | | | | | | | | | | | | When doing a releaseip event, we do them in parallel for all the separate IPs. This creates a problem for iptables, which isn't reentrant, giving the strange message: iptables encountered unknown error "18446744073709551615" while initializing table "filter" The worst possible symptom of this is that releaseip won't remove the rule which prevents us listening to clients during releaseip, and the node will be healthy but non-responsive. The simple workaround is to flock-wrap iptables. Better would be to rework the code so we didn't need to use iptables in these paths. CQ:S1018353 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (This used to be ctdb commit 72d6914ee913272312d7b68f1be5ad05ad06587d)
* functions: when checking for a directory also check whether it can be accessed.Michael Adam2010-05-111-1/+1
| | | | | | | | Thanks to "waKKu" on irc for this improvement. Michael (This used to be ctdb commit 81e1483dd0ce2cd091721e456c0c194cc58442f3)
* Merge root@10.1.1.27:/shared/ctdb/ctdb-gitRonnie Sahlberg2010-03-111-1/+2
|\ | | | | | | (This used to be ctdb commit e59310132d8126ee3afc191b5db56e80a32986e8)
| * ctdb_setstatus in /etc/ctdb/functions was not working correctly because it ↵Wolfgang Mueller-Friedt2010-03-111-1/+2
| | | | | | | | | | | | was called with a wrong parameter list (This used to be ctdb commit e1e285d9f7fa3237dbbacca52a4eb2b264fa5986)
* | Correct nice_service()Mathieu Parent2010-03-101-2/+11
| | | | | | | | | | | | nice takes a binary as argument and not a function or builtin command (This used to be ctdb commit e21b40db64b314a24caa2bc611cb48b93decb5aa)
* | config: make remove_ip() a wrapper of delete_ip_from_iface()Stefan Metzmacher2010-02-231-18/+8
| | | | | | | | | | | | metze (This used to be ctdb commit e66d6636b80e3614f183366ec92fc3c6d5c323da)
* | config: interface_modify states in a $CTDB_BASE/state/interface_modify directoryStefan Metzmacher2010-02-231-6/+27
| | | | | | | | | | | | metze (This used to be ctdb commit 756c8b953fef7132dae74b5b244baeb3108dec54)
* | config: add setup_iface_ip_readd_script() helper functionStefan Metzmacher2010-02-231-2/+21
|/ | | | | | | | | | This adds a generic infrastructure to register scripts which will be called when the delete_ip_from_iface() funtion needs to readd secondary ips to an interface. metze (This used to be ctdb commit ac97d65f44e8dc8bf2ec8f68e4db3448521755a2)
* eventscripts: stop loadconfig function from loading ctdb config file twice.Martin Schwenke2010-01-221-4/+3
| | | | | | | | | If "$1" was empty than loadconfig would load the ctdb config twice. This stops that from happening. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 0406d406da70aaee7ad6aac236114905c5d03ed2)
* config: add some ipv4 helper shell functionsStefan Metzmacher2010-01-201-0/+64
| | | | | | | | | Many thanks to Michael Adam <obnox@samba.org> for the basic work. metze (This used to be ctdb commit ff9c641763702ae99632bbf4d0825d578440c074)
* config: add interface_modify.sh and call it under flock to make modification ↵Stefan Metzmacher2010-01-201-3/+31
| | | | | | | | | | | on interfaces atomic When two releaseip events run in parallel it's possible that the 2nd script readds a secondary ip that was removed by the 1st script. metze (This used to be ctdb commit e02417b2a55c45ac2c125b1b3463c9c39e7bc07a)
* config/functions: add tickle_tcp_connections()Stefan Metzmacher2010-01-201-0/+30
| | | | | | metze (This used to be ctdb commit 2397f13d7b5ca3847ef148187c6b179d06f6a47a)
* Eventscript argument cleanups and introduction of ctdb_standard_event_handler.Martin Schwenke2009-12-011-17/+16
| | | | | | | | | | | | | | | | | | | The functions file no longer causes a side-effect by doing a shift. It also doesn't set a convenience variable for $1. All eventscripts now explicitly use "$1" in their case statement, as does the initscript. The absence of a shift means that the takeip/releaseip events now explicitly reference $2-$4 rather than $1-$3. New function ctdb_standard_event_handler handles the status and setstatus events, and exits for either of those events. It is called via a default case in each eventscript, replacing an explicit status case where applicable. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 3d55408cbbb3bb71670b80f3dad5639ea0be5b5b)
* Event scripts: functions file now intercepts status and setstatus.Martin Schwenke2009-11-271-0/+11
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit a1f37fdc5217e57d2d643d77a811afca747685e0)
* Event scripts: use $script_name rather than $service name for status.Martin Schwenke2009-11-251-7/+8
| | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 517e9d9b188b18dffc712a8fecddb41540d27b8d)