Forum Discussion

JJ_47859's avatar
JJ_47859
Icon for Nimbostratus rankNimbostratus
Apr 21, 2008

LB:server breaks my website

Hello,

 

 

We encountered a serious issue with out web application. I recently created an irule to redirect the users browser to an offline page if there were no servers available in the pool.

 

 

Here's the code:

 

when HTTP_REQUEST {

 

set mypool [LB::server]

 

if {[active_members $mypool] < 1 } {

 

log "all $mypool pool members are unavailable redirecting to maintenance page."

 

HTTP::redirect "http://offline.com"

 

}

 

}

 

 

Our some functionality of our web application broke after this code was implemented. I found that if I statically set the pool name then everything works.

 

 

Good code example:

 

when HTTP_REQUEST {

 

if {[active_members SERVERNAME] < 1 } {

 

HTTP::redirect "http://offline.com"

 

}

 

}

 

 

How can I find what LB::server is doing to break my web code?

 

 

Thanks.

3 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    This is likely due to the fact that there is no load balancing decision made until after the HTTP_REQUEST event. If you want to dynamically check the number of active members of the pool, you'll need to do so during or after the LB_SELECTED event, which signifies that the BIG-IP has actually made a load balancing decision, and chosen which node to send traffic to.

     

     

    Colin
  • LB::server returns a Tcl list with pool, node addr and port. [LB::server pool] is what you want when setting the pool name.
  • Not sure if you've come up with a solution to this already, but I've been using the following persistence iRule to get the load balancer to disable persistence and reselect from a pool of servers with outage content when the LB fails to get a member from the default pool. In my case, breaking the persistence and not having the redirect be visible to the end-user were requirements. May not be the cleanest way to do this, but it seems to work.

     

     

    when CLIENT_ACCEPTED {

     

    set pool_name [LB::server pool]

     

    if {[active_members $pool_name] == 0}{

     

    set ::persist 0

     

    log local0.crit "No available members in pool \"$pool_name\": reselecting from pool \"sorry\"."

     

    } else {

     

    set ::persist 1

     

    }

     

    }

     

    when HTTP_REQUEST {

     

    if { [HTTP::cookie exists "JSESSIONID"] and $::persist>0} {

     

    persist uie [HTTP::cookie "JSESSIONID"]

     

    }

     

    }

     

    when HTTP_RESPONSE {

     

    if { [HTTP::cookie exists "JSESSIONID"] and $::persist>0} {

     

    persist add uie [HTTP::cookie "JSESSIONID"]

     

    }

     

    }

     

    when LB_FAILED {

     

    if {$::persist==0}{

     

    LB::detach

     

    LB::reselect pool "sorry"

     

    }

     

    }