LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: [lvs-users] [Keepalived-devel] Weight being reset

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>, keepalived-devel <keepalived-devel@xxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [lvs-users] [Keepalived-devel] Weight being reset
From: Scott McClanahan <scott.mcclanahan@xxxxxxxxxxxx>
Date: Mon, 14 Jan 2008 16:01:39 -0500
On Mon, 2008-01-14 at 15:47 -0500, Graeme Fowler wrote:
> Hi
> 
> Will cc this to keepalied list as you posted there too :)
> 
> On Mon, 2008-01-14 at 11:19 -0500, Scott McClanahan wrote:
> > We run ipvs with keepalived (CentOS 5.1) and often change the
> run-time
> > configuration of real servers by manipulating there weights.  Our
> > problem is if the backend real server reboots or the application
> > restarts, the weight gets reset to the value in the keepalived
> config
> > file which is often times not what we want.
> 
> You probably need the following (see keepalived.conf.SYNOPSIS or the
> man
> page), edited slightly, in your virtual_server or virtual_server_group
> definitions:
> 
> MISC_CHECK {                            # MISC healthchecker
>   misc_path <STRING>|<QUOTED-STRING>  # External script or program
>   misc_timeout <INTEGER>              # Script execution timeout
> 
>   # If set, exit code from healthchecker is used
>   # to dynamically adjust the weight as follows:
>   #   exit status 0: svc check success, weight
>   #     unchanged.
>   #   exit status 1: svc check failed.
>   #   exit status 2-255: svc check success, weight
>   #     changed to 2 less than exit status.
>   #   (for example: exit status of 255 would set
>   #     weight to 253)
>   misc_dynamic
> }
> 
> My reading of that is that you replace your healthcheck scripts with a
> MISC_CHECK that can lookup the set weight in some way (in a file, a
> database, or by parsing the output from ipvsadm - TMTOWTDI, in Perl
> parlance) and then return a value appropriate to your circumstance.
> 
> Example:
> 
> You configure an HTTP realserver with weight 100 in keepalived.conf.
> You
> have a MISC_CHECK script which uses wget, LWP or something to check
> the
> web service is running.
> 
> You want to turn the weight down to 75.
> 
> Your MISC_CHECK script, as well as doing a health check, can do a
> lookup
> in a file (say /etc/keepalived/weights/$virtual_server). If the file
> doesn't exist, skip the weight setting. If it does, read the contents
> and set the return code appropriately.
> 
> For the avoidance of confusion, you put the *real* weight - 75 - in
> the
> file. The MISC_CHECK then does some meta-logic:
> 
>   Is the service healthy?
>     No? Exit 1 (ie. fail)
>     Yes?
>   Does /etc/keepalived/weights/$virtual_server exist?
>     No? Skip this part.
>     Yes? Read the file and fetch $value.
>   Is the value numeric, from 2-255?
>     No? Log the error, Exit 0 (ie. success)
>     Yes?
>   Exit $value+2 (ie. success, change weight to $value)
> 
> This is untried/untested but if I read you right it should work.
> 
> The joy of this is that the weight will then remain at whatever you
> set
> it to in the file *and* persist across service, server, keepalived or
> director restarts as long as the file exists.
> 
> Graeme
> 

Thanks for the response but I think the easiest and best approach for me
would simply be to mod the config with the appropriate weight (this
doesn't happen so frequently that it's a burden) and perform a reload.

I just need to be sure keepalived handles a HUP signal as I'd expect.  I
noticed in previous releases HUP signals weren't always handled so
gracefully.  I'd like to make sure the master stays master and
interruptions to users are avoided.



<Prev in Thread] Current Thread [Next in Thread>