LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: LVS with Ldirectord (UltraMonkey) problems

To: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: LVS with Ldirectord (UltraMonkey) problems
From: Horms <horms@xxxxxxxxxxxx>
Date: Tue, 3 Sep 2002 17:46:49 +0900
On Fri, Aug 30, 2002 at 09:22:54AM +0200, Martijn Klingens wrote:
> On Thursday 29 August 2002 18:10, Craig Ward wrote:
> > That's fixed it for me, but I don't know $tmp_id or $virtual_id actually
> > is.
> >
> > If anyone could enlighten me that'd be great :o)
> 
> Not sure what that code does either, but my ldirectord CVS copy does 
> something 
> slightly different at that point in the code:
> 
> ----
>       # Check each virtual service for the real server and make
>       # changes as neccessary
>       foreach $v (@VIRTUAL){
>               # Use found rather than relying on tmp_id being
>               # set when we leave the foreach loop. There
>               # seems to some weirdness in Perl (5.6.0 on Redhat 7.2)
>               my $found = 0;
>               my $tmp_id;
>               my $virtual_id = get_virtual_id_str($v);
>               foreach $tmp_id (@$virtual) {
>                       if($virtual_id eq $tmp_id) {
>                               $found = 1;
>                               last;
>                       }
>               }
>               if ($found == 1) {
>                       if ($state=~/up/i) {
>                               $$r{status}=0;
>                               _service_up($v, $r);
>                               &ld_debug(2, "Enabled server=$$r{server}");
>                       } elsif ($state=~/down/i) {
>                               $$r{status}=1;
>                               _service_down($v, $r);
>                               &ld_debug(2, "Disabled server=$$r{server}");
>                       }
>               }
>       }
> ----
> 
> Not sure if this can be dropped in, it might be dependent on the rest of the 
> ldirectord script. Maybe you can try the CVS version?

Sorry for the delay in responding to this thread. I have been on holidays.

The code that is in CVS for the section above, is slightly different to
that which Craig Ward was using. The functionality is the same, however
there apears to be a bug in some versions of perl such that the original
code did not work.

The problem is that the iterator $tmp_id gets unset when the foreach
loop ends by calling last, rather than retaining the most recent value
set.  Thus I used a separate variable $found to idicate if a match was
found or not.  This bug manifests in the version of perl that that ships
with Red Hat 7.2, perl-5.6.0-17, but not with the version on my debian
box that I origionally developed the code on, perl-5.6.1-7. 

Craig Wood's patch looks a little broken to me at a glance, so I would
go for the code out of CVS, as above. This code seems to work for both
the versions of perl mentioned above, and I assume all other versions as
well.

-- 
Horms
        


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