Lars Marowsky-Bree schrieb: > On 2007-04-07T22:23:32, Michael Schwartzkopff <[EMAIL PROTECTED]> wrote: > > Hi Michael, > > thanks for fixing the ClusterIP support in IPaddr2 up! Great job! > > Can you please sent the changes as a unified diff for review? > > Also, has the kernel crash been reported anywhere? I'd like to get that > fixed as well. > > > Sincerely, > Lars > > Hi,
diff: I do want some testing before this changs from alpha to something real. Please help testing. Just copy the script to /usr/lib/ocf... . Please also find diff -bu attached. Kernel crash: See https://bugzilla.novell.com/show_bug.cgi?id=238646 Oops: I just noticed that you are responsoble for that bug since Jan 25th 2007. Michael.
--- IPaddr2 2007-03-31 18:41:37.000000000 +0200 +++ /usr/lib/ocf/resource.d/heartbeat/IPaddr2 2007-04-09 19:59:51.000000000 +0200 @@ -1,14 +1,17 @@ #!/bin/sh # # $Id: IPaddr2.in,v 1.24 2006/08/09 13:01:54 lars Exp $ +# IPaddr2, v1.30 2007/02/04, MS # # OCF Resource Agent compliant IPaddr2 script. # # Based on work by Tuomo Soini, ported to the OCF RA API by Lars # Marowsky-Brée. Implements Cluster Alias IP functionality too. +# MS Implementing load sharing via clusterip target of iptables. # # Copyright (c) 2003 Tuomo Soini # Copyright (c) 2004-2006 SUSE LINUX AG, Lars Marowsky-Brée +# Copyright (c) 2007 Michael Schwartzkopff # All Rights Reserved. # # This program is free software; you can redistribute it and/or modify @@ -34,12 +37,20 @@ # TODO: -# - Fix up Cluster IP functionality # - There ought to be an ocf_run_cmd function which does all logging, # timeout handling etc for us # - Make this the standard IP address agent on Linux; the other # platforms simply should ignore the additional parameters OR can use # the legacy heartbeat resource script... +# - Validate all parameters, esp clone... Do not allow load sharing if LVS +# - Check LVS <-> clusterip incompatibilities. +# - At the moment LOAD_SHARE has to be enabled explicitely, but I think that +# should not be nescessary if meta_clone is set. Are there cases where the +# user wants a clone ressource, but no load sharing on Linux systems? +# - If you use load share be sure to make the clone resource ordered or +# really bad things will happen. This is due to the fact that "local_node" +# has to be given during fist initialisation of the CLUSTERIP target. +# There should be a workaround for this. # # OCF parameters are as below # OCF_RESKEY_ip @@ -48,14 +59,14 @@ # OCF_RESKEY_cidr_netmask # OCF_RESKEY_iflabel # OCF_RESKEY_mac -# OCF_RESKEY_incarnations_max_global -# OCF_RESKEY_incarnation_no (not user-configurable) # OCF_RESKEY_clusterip_hash -# OCF_RESKEY_clusterip_mark # OCF_RESKEY_arp_interval # OCF_RESKEY_arp_count # OCF_RESKEY_arp_bg # OCF_RESKEY_arp_mac +# +# OCF_RESKEY_CRM_meta_clone +# OCF_RESKEY_CRM_meta_clone_max ####################################################################### @@ -65,7 +76,7 @@ HA_VARRUNDIR=/var/run/heartbeat IP2UTIL="/sbin/ip" -IPTABLES="/usr/sbin/iptables" +IPTABLES=/usr/sbin/iptables MODPROBE="/sbin/modprobe" SENDARP=$HA_BIN/send_arp FINDIF=$HA_BIN/findif @@ -143,6 +154,15 @@ <content type="string" default=""/> </parameter> +<parameter name="load_share"> +<longdesc lang="en"> +Enable load sharing via clusterip target of iptables. Be sure to have +iptables with clusterip target compiled in. +</longdesc> +<shortdesc lang="en">Enable load sharing</shortdesc> +<content type="boolean" default="false"/> +</parameter> + <parameter name="lvs_support"> <longdesc lang="en"> Enable support for LVS Direct Routing configurations. In case a IP @@ -154,16 +174,6 @@ <content type="boolean" default="false"/> </parameter> -<parameter name="incarnations_max_global"> -<longdesc lang="en"> -If you wish the IP address to be active on more than one node, set this -to the number of hash buckets you wish to use. - -</longdesc> -<shortdesc lang="en">Global number of hash buckets</shortdesc> -<content type="integer" default="1"/> -</parameter> - <parameter name="mac"> <longdesc lang="en"> Set the interface MAC address explicitly. Currently only used in case of @@ -183,15 +193,6 @@ <content type="string" default="sourceip-sourceport-destport"/> </parameter> -<parameter name="clusterip_mark"> -<longdesc lang="en"> -Specify the mark value used to mark the connection by CONNMARK target. - -</longdesc> -<shortdesc lang="en">Mark value</shortdesc> -<content type="string" default="1"/> -</parameter> - <parameter name="arp_interval"> <longdesc lang="en"> Specify the interval between unsolicited ARP packets in milliseconds. @@ -285,10 +286,17 @@ LVS_SUPPORT=1 fi - IP_INC_GLOBAL=${OCF_RESKEY_incarnations_max_global:-1} - IP_INC_NO=${OCF_RESKEY_incarnation_no:-0} - IP_CIP_HASH="$OCF_RESKEY_clusterip_hash" - IP_CIP_MARK=${OCF_RESKEY_clusterip_mark:-1} + LOAD_SHARE=0 + if [ x"${OCF_RESKEY_load_share}" = x"true" \ + -o x"${OCF_RESKEY_load_share}" = x"on" \ + -o x"${OCF_RESKEY_load_share}" = x"1" \ + -o x"${OCF_RESKEY_load_share}" = x"yes" ]; then + LOAD_SHARE=1 + fi + + IP_INC_GLOBAL=${OCF_RESKEY_CRM_meta_clone_max:-1} + IP_INC_NO=$((OCF_RESKEY_CRM_meta_clone+1)) + IP_CIP_HASH="${OCF_RESKEY_clusterip_hash}" ARP_INTERVAL_MS=${OCF_RESKEY_arp_interval:-200} ARP_REPEAT=${OCF_RESKEY_arp_count:-5} @@ -336,7 +344,8 @@ IP_CIP= - if [ "$IP_INC_GLOBAL" -gt 1 ]; then + if [ "$IP_INC_GLOBAL" -gt 1 -a $LOAD_SHARE -gt 0 ]; then + ocf_log info "user wants load share" if [ ! -x "$IPTABLES" ]; then ocf_log err "Cluster Alias IP mode selected, but iptables not configured" exit $OCF_ERR_INSTALLED @@ -509,6 +518,10 @@ # run_send_arp() { ARGS="-i $ARP_INTERVAL_MS -r $ARP_REPEAT -p $SENDARPPIDFILE $NIC $BASEIP auto $BASEIP $ARP_NETMASK" + if [ $IP_CIP="yes" ] ; then + MY_MAC=${IF_MAC//:/} + ARGS="-i $ARP_INTERVAL_MS -r $ARP_REPEAT -p $SENDARPPIDFILE $NIC $BASEIP $MY_MAC $BASEIP $ARP_NETMASK" + fi ocf_log info "$SENDARP $ARGS" case $ARP_BACKGROUND in yes) @@ -549,11 +562,12 @@ fi # Special handling for the CIP: - if grep -q "\<${IP_INC_NO}\>" $IP_CIP_FILE ; then + if grep -q "^${IP_INC_NO},\|,${IP_INC_NO},\|,${IP_INC_NO}$\|^${IP_INC_NO}$" $IP_CIP_FILE ; then echo "ok" return 0 else - return "partial" + echo "partial" + return 0 fi exit $OCF_ERR_GENERIC @@ -582,16 +596,7 @@ fi if [ -n "$IP_CIP" ] && [ $ip_status = "no" ]; then - $MODPROBE ip_tables $MODPROBE ip_conntrack - $MODPROBE ipt_CLUSTERIP - $IPTABLES -A OUTPUT -s $BASEIP -o $NIC \ - -m state --state NEW \ - -j CONNMARK --set-mark $IP_CIP_MARK - if [ $? -ne 0 ]; then - ocf_log err "iptables failed" - exit $OCF_ERR_GENERIC - fi $IPTABLES -I INPUT -d $BASEIP -i $NIC -j CLUSTERIP \ --new \ --clustermac $IF_MAC \ @@ -662,16 +667,15 @@ fi echo "-$IP_INC_NO" >$IP_CIP_FILE if [ "x$(cat $IP_CIP_FILE)" = "x" ]; then - # This was the last incarnation - $IPTABLES -D OUTPUT -s $CLUSTERIP -o $NIC \ - -m state --state NEW \ - -j CONNMARK --set-mark $IP_CIP_MARK + ocf_log info $BASEIP, $IP_CIP_HASH $IPTABLES -D INPUT -d $BASEIP -i $NIC -j CLUSTERIP \ --new \ --clustermac $IF_MAC \ --total-nodes $IP_INC_GLOBAL \ --local-node $IP_INC_NO \ --hashmode $IP_CIP_HASH + $MODPROBE -r ipt_CLUSTERIP + $MODPROBE -r ip_conntrack else ip_del_if="no" fi @@ -695,7 +699,9 @@ ip_init # TODO: Implement more elaborate monitoring like checking for # interface health maybe via a daemon like FailSafe etc... - case `ip_served $BASEIP` in + + local ip_status=`ip_served` + case $ip_status in ok) return $OCF_SUCCESS ;; @@ -742,43 +748,48 @@ ;; esac - mark=$IP_CIP_MARK - case $mark in - +*|-*) - mark=$(echo $mark | cut -c 2-) - ;; - esac - case $mark in - 0x*) # hexidecimal - mark=$(echo $mark | cut -c 3-) - if [ -n "$mark" ] && ocf_is_hex "$mark"; then - : - else - valid=0 - fi - ;; - 0*) # octal - mark=$(echo $mark | cut -c 2-) - if [ -n "$mark" ] && ocf_is_octal "$mark"; then - : - else - valid=0 - fi - ;; - *) # decimal - if [ -n "$mark" ] && ocf_is_decimal "$mark"; then - : - else - valid=0 - fi - ;; - esac - - if [ $valid -eq 0 ]; then - ocf_log err "Invalid OCF_RESKEY_clusterip_mark [$IP_CIP_MARK]" + if [ "$LVS_SUPPORT" = 1 ]; then + ecf_log err "LVS and load sharing not advised to try" exit $OCF_ERR_ARGS fi +# mark=$IP_CIP_MARK +# case $mark in +# +*|-*) +# mark=$(echo $mark | cut -c 2-) +# ;; +# esac +# case $mark in +# 0x*) # hexidecimal +# mark=$(echo $mark | cut -c 3-) +# if [ -n "$mark" ] && ocf_is_hex "$mark"; then +# : +# else +# valid=0 +# fi +# ;; +# 0*) # octal +# mark=$(echo $mark | cut -c 2-) +# if [ -n "$mark" ] && ocf_is_octal "$mark"; then +# : +# else +# valid=0 +# fi +# ;; +# *) # decimal +# if [ -n "$mark" ] && ocf_is_decimal "$mark"; then +# : +# else +# valid=0 +# fi +# ;; +# esac +# +# if [ $valid -eq 0 ]; then +# ocf_log err "Invalid OCF_RESKEY_clusterip_mark [$IP_CIP_MARK]" +# exit $OCF_ERR_ARGS +# fi + case $IF_MAC in ??[^0-9]??[^0-9]??[^0-9]??[^0-9]??[^0-9]??) mac=${IF_MAC:0:2}${IF_MAC:3:2}${IF_MAC:6:2}${IF_MAC:9:2}${IF_MAC:12:2}${IF_MAC:15:2} @@ -804,9 +815,15 @@ fi + # MS, 28.3.07 + # TODO: Validate if clusterip AND clone_ordered AND clone_interleave + # otherwise kernel crash + exit $OCF_SUCCESS } +ocf_log info $__OCF_ACTION, $OCF_RESKEY_ip, $OCF_RESKEY_clusterip_hash, $OCF_RESKEY_CRM_meta_clone, $OCF_RESKEY_CRM_meta_clone_max + case $__OCF_ACTION in meta-data) meta_data ;;
_______________________________________________ Linux-HA mailing list Linux-HA@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha See also: http://linux-ha.org/ReportingProblems