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

80 Commits

Author SHA1 Message Date
Martin Schwenke
4b5c9c7991 eventscripts: Get list of configured interfaces using "ctdb ifaces"
This was previosuly changed because ctdbd didn't garbage collect
orphaned interfaces.  This was fixed in commit
cc1a3ae911d3fee8b87fda5de5ab6d9499d7510a.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit c6ab0f9405d5fa5b0b1693bc92e59da0d555a9d7)
2013-07-19 15:35:41 +10:00
Martin Schwenke
297b98d5b6 eventscripts: Each script should set CTDB_BASE if it is not set
This makes it easier to run the scripts externally.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 740ea8ea5084149c8b552a01ee1c98c558b12384)
2013-01-08 15:18:46 +11:00
Martin Schwenke
8fad7670f1 Eventscripts: 10.interface should list configured interfaces
The current code lists available interfaces.  If IPs are configured in
some other way than the public addresses file (e.g. ctdb addip) and their
interfaces default to being marked down then, since down interfaces are
not available, these interfaces can never be marked up.

The configured interfaces should be listed instead.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit d8f010355b715e49709836e057a5d0f110919897)
2012-11-19 15:54:50 +11:00
Martin Schwenke
f082f4006f Eventscripts: 10.interface startup event should only process interfaces once
Provided that monitor_interfaces() sets the state of each interface,
there's no need to mark all interfaces as up before running
monitor_interfaces() in the startup event.  monitor_interfaces() will
set the true status of each interface anyway.  The duplication is
unnecessary and may cause extra action in the recovery daemon because
the state of some interfaces is changed an extra time.

Instead, add a comment at the top of the loop in monitor_interfaces()
to warn against early loop exits.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit f243a916ee71013f7402b9c396c2ead88eb3aab0)
2012-11-14 10:57:48 +11:00
Martin Schwenke
66d0aba85b Revert "Eventscripts - add facility to 10.interface to delete unmanaged IPs"
This reverts commit 88f88d86b0d08240f749fb721b8c401c2eeb1099.

This is dangerous and, on reflection, I can't see it being useful.
There are often permanent IPs on interfaces that CTDB shares with its
public IPs.

(This used to be ctdb commit 16aba4eb620844626a1c71c58b51658caf44dea6)
2012-10-18 20:05:42 +11:00
Martin Schwenke
162ac70f9e Eventscripts - add facility to 10.interface to delete unmanaged IPs
For a number of reasons (delip failure, admin stupidity, ...) an
interface that hosts public addresses can also contain spurious,
unmanaged addresses.

Add functionality to 10.interfaces, controlled by new configuration
variable CTDB_DELETE_UNEXPECTED_IPS, to delete these addresses when
encountered as part of a monitor event.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 88f88d86b0d08240f749fb721b8c401c2eeb1099)
2011-11-17 16:47:00 +11:00
Mathieu Parent
7f1ff4dbd8 Less verbosity when there is no public addresses file
This partialy reverts 81eff51, but still avoid spam.

(This used to be ctdb commit e646142f4d28b5401235cd5edee325f7a29f8193)
2011-10-12 20:07:03 +11:00
Martin Schwenke
bc4e62be85 Eventscripts - call ctdb_check_args() instead of doing hand checking
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit cc5bc1948dcbe8b8b25185260927b94a4b529174)
2011-08-30 09:33:47 +10:00
Ronnie Sahlberg
81292ac0e6 Change the errors for 10.interface to clearly state ERROR: for error messages
Update the tests system to catch the new error strings generated by this change

(This used to be ctdb commit a2c30d88348da47d1a733a16e4c7d83c3becb6df)
2011-08-15 15:53:04 +10:00
Martin Schwenke
c9d168bbe4 Eventscripts: 10.interfaces - make startup event actually mark interfaces up!
The startup event intends to mark interfaces up.  However, it doesn't
actually do that because $INTERFACES is empty.

This uses the function get_all_interfaces() to list the
interfaces... and then mark them up.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit fc62bf0975c6059ee467285565d0dc3b4daaf238)
2011-08-12 16:34:34 +10:00
Martin Schwenke
5ab955a73d Eventscripts: 10.interfaces - startup comment says assume all interfaces good.
Interfaces are currently marked down.  Mark them up instead, as per
the comment... and discussion with Ronnie.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 35942841229cc72ce363a7236aec708f1a33136b)
2011-08-12 16:34:34 +10:00
Martin Schwenke
e7963d8a65 Eventscripts: 10.interfaces - new function get_all_interfaces().
Move existing interface listing code to new function in preparation
for using it in startup event.

While we're here change the "sort | uniq" into "sort -u" and save some
complexity.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit cd1442531ad079b11c60f46ee9d34f5104bef219)
2011-08-12 16:34:34 +10:00
Martin Schwenke
9bdcdb76be Eventscripts: 10.interface clean-ups - minor tweaks and new comments.
* sed can read files, it doesn't need a file piped to it
* use $() subshells instead of `` - they seem to quote better in dash
* tweak the uniquifying code so that it is easier to read
* add comments
* remove some extraneous semicolons at ends of lines

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 5f49537889a92c3cb68d9203912188bedf00ecd4)
2011-08-12 16:34:13 +10:00
Martin Schwenke
7c33fb1711 Eventscripts: 10.interface clean-ups - variable name fix-ups.
Change most of the uppercase variable names to lowercase for
consistency with other variables, readability and so they can be
easily distinguished from environment/configuration variables.  Change
the name of 2 of the variabless to add some clarity.  Changes are as
follows:

  INTERFACES   -> all_interfaces
  IFACES       -> ctdb_interfaces
  IFACE        -> iface
  I            -> i
  REALIFACE    -> realiface

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 7b201c1087b1433cfbc95de76cb4205e484ccd6f)
2011-08-12 15:57:34 +10:00
Martin Schwenke
6fa27bdf18 Eventscripts: 10.interfaces clean-ups - push logic into monitor_interfaces().
The logic in the monitor event itself is very complex.  Nearly all of
it can go away by adding a single check of
$CTDB_PARTIALLY_ONLINE_INTERFACES to the return logic of
monitor_interfaces() and reversing the sense of the corresponding
check.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit fa93177442c65c2a4eb2d5d5dba0a0da1c486969)
2011-08-12 15:00:03 +10:00
Martin Schwenke
00c4cc6d22 Eventscripts: 10.interfaces clean-up - use more descriptive variable names.
The name of variable $ok gives no clue to its meaning/use so this
changes that variable to be named $up_interfaces_found.

The return logic relating to $ok and $fail is difficult to read, so
these variables are given true/fale values, allowing the return logic
to be simplified.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 3402930319d462eab5525410f6a676952e120182)
2011-08-12 14:49:27 +10:00
Martin Schwenke
bb5db84021 Eventscripts: 10.interfaces cleanup - new functions mark_up(), mark_down().
The same few lines of logic are used every time an interface up or down.

This encapsulates those few lines in 2 new functions.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit ab443c4d7d282f282792abc6a6ac224ab06abe30)
2011-08-12 14:43:15 +10:00
Martin Schwenke
4e60075228 Eventscripts - fix 10.interface bash incompatibility.
In dash, this fails gracefully with nothing to stderr:

  t=$(cat /does_not_exist) 2>/dev/null

In bash the error from cat is still printed due to different order of
evaluation.

This works everywhere:

  t=$(cat /does_not_exist 2>/dev/null)

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit a6e61867c7a58d5a77cd8641d8df0b105cddff77)
2011-08-10 16:06:26 +10:00
Martin Schwenke
eec654314a Eventscripts - Remove local variable usage in 10.interfaces.
POSIX sh doesn't have local variables.  Debian's dash doesn't behave
the same way as bash on this contruct:

  local var=`command that produces multiple words`

It only assigns the 1st word and may print an error.

Just remove the use of the "local" keyword in monitor_interfaces() to
solve this.  It isn't actually limiting the scope of any variables
that are used outside the function.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 95d9a1e19655461288a2c7e52abf9d01ab23e05a)
2011-08-08 15:44:30 +10:00
Martin Schwenke
8026b3ce5a Eventscripts - Rework the use of get_proc() for the bonding checks.
Call call_proc(), put the output into a variable and then use it.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 2dfdc997f432d522034922b43cb6f8f878d11ba7)
2011-08-03 20:12:48 +10:00
Martin Schwenke
4b516600a2 Eventscripts: update 10.interface to use set_proc() and get_proc().
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 61b7f0172ba5c83c847c29fac3582c25c7754b68)
2011-08-03 19:58:25 +10:00
Martin Schwenke
652bf326e1 Eventscripts - 10.interfaces should not check orphaned interfaces.
If the last IP address on an interfaces is removed then that
interfaces should no longer be checked by 10.interfaces.  However,
"ctdb ifaces" still lists such interfaces so they are currently
checked.

The problem really needs to be addressed in ctdbd but a neat quick
eventscript fix will be minimally invasive...

This changes the code to use "ctdb -Y ip -v" instead of "ctdb -Y
ifaces".  The former includes details of all public addresses and
associated interfaces, so when an address is removed there is no
output for it.  This avoids orphaned interfaces from being listed.

The logic is also slightly improved so that $IFACES includes just a
(non-uniquified) list of interfaces, allowing an existing loop to be
removed.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 49b2d1bd9554461ed8edbfc21e777c0eca9e1443)
2011-08-02 16:53:14 +10:00
Ronnie Sahlberg
ee9e137759 Dont exit from checking interfaces once we have found one interface that is not
in use by public addresses.   this can happen when we have removed existing interfaces/ip addresses and prevents us from verifying the status of other interfaces

(This used to be ctdb commit d67955b42f7627be9dae995230c8fcbb8a948ec2)
2011-05-10 07:53:43 +10:00
Ronnie Sahlberg
2e2e37fdd6 Remove logging of spam/errors from the 10.interfrace
script if/when we have for example NATGW configured but no public addresses defined on that interface

CQ S1023378

(This used to be ctdb commit 8837daa424732aeb5a20814b1709c345a97a0e09)
2011-05-09 08:10:49 +10:00
Ronnie Sahlberg
d97e42183e bonding mode 4 monitoring:
we can not just check if MII Status is up for bonding mode 4, since the kernel will always report the bond device as UP
even if all cables are disconneccted.

For mode 4, ignore the status of the bond device and instead chek if at least one slave interface is up
when determining if the device is good or bad

(This used to be ctdb commit a6930cec6d9503dba18b9d4839d87a1c1a8ddba2)
2011-04-13 09:05:58 +10:00
Ronnie Sahlberg
c04505724a IFACE handling. Assume links are always good on nstartup (they almost always
Simplify the handling of setting the links in the 10.interface eventscript
and remove the optimization to only call setifacelink on state change
to make the code simpler to read.

If a take ip event fails, flag the node as unhealthy.

Add a check to the interface script to check if the interface exists
or if it has been deleted.
So that we can capture and become UNHELTHY if someone deletes an interface
we are using to host public addresses.

(This used to be ctdb commit 4ab63d2a7262aff30d5eced184c294c9c9dd4974)
2011-04-11 07:40:05 +10:00
Ronnie Sahlberg
055eafb790 this stuff is just so fragile that it will enter infinite recovery and fail loops
on any kind of tiny unexpected error

unconditionally try to remove ip addresses from both old and new interface
before trying to add it to the new interface to make it less
fragile

(This used to be ctdb commit 80acca2c91c9053c799365bae918db7ed8bdc56f)
2010-11-10 14:55:25 +11:00
Ronnie Sahlberg
ebed26d755 delete from old interface before adding to new interface
this stops the script from failing with an error if
both interfaces are specified as the same, which otherwise breaks and leads to an infinite recovery loop

(This used to be ctdb commit 565de03a784ed441490f8cd0b137b5cec8716d55)
2010-11-10 14:55:25 +11:00
Ronnie Sahlberg
76578b9533 dont delete all ips from the system during the initial "init" event
leave any ips as they are and let the recovery daemon remove them as required

(This used to be ctdb commit 8ab311719857847b4cf327507b0af1793551e73c)
2010-11-10 14:55:23 +11:00
Ronnie Sahlberg
f7febd28af dont stop checking interfaces after the first bond device
continue the loop to process all other interfaces too

(This used to be ctdb commit 500ade4e6a58ea786a665f6be7cf30f43c882570)
2010-10-09 10:55:43 +11:00
Stefan Metzmacher
794230775c events/10.interface: we need to mark interfaces as "up" if we don't know how to monitor them
metze

(This used to be ctdb commit 1e08d1578d1960fcfc5fdd85492fbd6d194e5e94)
2010-07-30 16:33:27 +10:00
Ronnie Sahlberg
004b849feb Dont check linkstatus for loopback. This interface never has
issues with the physical layer

(This used to be ctdb commit d938b80a1c409a9ec4b554ddca5b0d949be53d9e)
2010-06-01 14:51:09 +10:00
Ronnie Sahlberg
40434a7c98 add a missing ||
to make the 10.interface script not fail with a syntax error

(This used to be ctdb commit a9831070344a6dcf46c55250f9d74a5870f37dfe)
2010-04-22 14:22:46 +10:00
Martin Schwenke
f765f0ceca Fix a thinko in 2ea0a9f1a93781a0d036feb9fcc0d120b182922f.
If the driver is virtio_net then we assume that the link is up rather
than ignoring the check altogether.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 3044d07da2a58260fa06bf489890b279bcf3ec39)
2010-04-20 10:52:31 +10:00
Ralph Wuerthner
d2f7bf804c ethtool does not support virtio_net devices.
Skip link test for this type of devices

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 2ea0a9f1a93781a0d036feb9fcc0d120b182922f)
2010-04-15 16:38:19 +10:00
Stefan Metzmacher
061c2a7182 config/10.interface: use delete_ip_from_iface also in the "init" event
metze

(This used to be ctdb commit e2bc5c25116747c58505fe1cb3e2d164257377d1)
2010-02-23 10:38:49 +01:00
Stefan Metzmacher
12c8dd215c config: 10.interface: search "ethtool" in $PATH instead of using a hardcoded path
This is very useful for testing, I use such a script:

cat ~/bin/ethtool
 #!/bin/sh

 IFACE=$1

 case "$IFACE" in
        Neth2)
                ;;
        Neth3)
                ;;
        Neth4)
                ;;
        Neth5)
                ;;
        *)
                exec /usr/sbin/ethtool $@
                ;;
 esac

 ip link set down $IFACE

 exec /usr/sbin/ethtool $@

metze

(This used to be ctdb commit 3bab985cf615720eded4d47b4f9f37a9c28840aa)
2010-01-20 11:11:04 +01:00
Stefan Metzmacher
6a818e66ae events: 10.interface handle updateip event
metze

(This used to be ctdb commit a5cdf1277387f8c6292153c37fa9ceb64707d04f)
2010-01-20 11:11:02 +01:00
Stefan Metzmacher
50bff8c886 config: add CTDB_PARTIALLY_ONLINE_INTERFACES to ctdb.sysconfig
With this option set to "yes", we don't become unhealthy
as long as at least one interface is still available.

metze

(This used to be ctdb commit d054eb33c6ae92560cddb40732e5dcf622591a3c)
2010-01-20 11:11:01 +01:00
Stefan Metzmacher
5d2c3ef656 config: 10.interfaces call monitor_interfaces on startup
metze

(This used to be ctdb commit 615dec051c26aac628f120e96bf12fb39fc6d28a)
2010-01-20 11:11:01 +01:00
Stefan Metzmacher
94e7101070 config: 10.interfaces call ctdb ifaces and ctdb setifacelink for monitoring
metze

(This used to be ctdb commit c465f63585c419ba59a6b04cbbf78ae615a7259d)
2010-01-20 11:11:01 +01:00
Stefan Metzmacher
9c89dd9210 events: splitout a monitor_interfaces function in 10.interface
metze

(This used to be ctdb commit b5ba56dea57db97d6c6ba3e7582e74fe0e3041fc)
2010-01-20 11:11:01 +01:00
Stefan Metzmacher
9a43f5e42b events: 10.interfaces allow multiple interfaces per public address
metze

(This used to be ctdb commit f9837f8b6f887d28f29aeb3eeffe8cfb423b40b4)
2010-01-20 11:10:58 +01:00
Stefan Metzmacher
4493ba6ffa config: add interface_modify.sh and call it under flock to make modification 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)
2010-01-20 11:10:48 +01:00
Stefan Metzmacher
c251ac20fa events/10.interfaces: move some parts to helper functions
metze

(This used to be ctdb commit 24cd42769d8f32b90a8876a6a08a36ab23076cd1)
2010-01-20 09:44:37 +01:00
Stefan Metzmacher
fd06167caa server: add "init" event
This is needed because the "startup" event runs after the initial recovery,
but we need to do some actions before the initial recovery.

metze

(This used to be ctdb commit e953808449c102258abb6cba6f4abf486dda3b82)
2010-01-20 09:44:36 +01:00
Ronnie Sahlberg
50820f9e18 Bond devices can have any name the user configures, so
when checking link status for an interface, first
check if this interface is in fact a bond device
(by the precense of a /proc/net/bonding/IFACE file)
and use that file for checking status.

Othervise assume ib* is an infiniband interface which we donnt know how
to check, or otherwise it is an ethernet interface and ethtool should
hopefully work.

(This used to be ctdb commit 8cc6c5de3d7abb0b72eaa6e769e70963b02d84cb)
2009-12-09 11:33:04 +11:00
Ronnie Sahlberg
3ca3f4c771 make sure to also check that interfaces used for NATGW are ok
and have a link.
if not the node should become unhealthy

(This used to be ctdb commit 03b5bbaae1b53830a4cd20d3079ab8f45ffce923)
2009-12-09 11:13:29 +11:00
Martin Schwenke
db25ca69e5 Eventscript argument cleanups and introduction of ctdb_standard_event_handler.
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)
2009-12-01 17:43:47 +11:00
Martin Schwenke
ee513c1ba2 More untested eventscript factorisation.
Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit ac655b0a65b32d809d47fec9821f7f31bb2fe2a7)
2009-11-19 15:00:17 +11:00