Forum Discussion
Erki_Märks_2779
Jan 26, 2011Nimbostratus
drain connections
There are two virtual servers, each have 1 pool with 2 nodes attached to it. The IP addresses of these nodes are the same for both of the pools, only port numbers differ. One node for instance 1.1.1.1 is primary and 1.1.1.2 is the secondary in each of these pools. The application is built so that it connects to the server logs in and the connection remains open. If 1.1.1.1 xx goes down, all connections should go to 1.1.1.2 and connections to 1.1.1.1 should be dropped. For that reason, the action on svcdown is set to drop on both of those pools, but even if i do LB::down and LB::down pool xxx member x.x.x.x xx, the connections stay open. Is there a way to do b conn server 2.2.2.2:80 delete from an irule.
when RULE_INIT
{
if {not([array exists ::arr])}
{
array set ::arr {
"primary" "1.1.1.1"
"secondary" "1.1.1.2"
}
}
}
when CLIENT_ACCEPTED
{
set port "xxxy"
set pool "pool_$port"
set portsec "xxxx"
set poolsec "pool_$portsec"
if { [active_members $pool] > 0 && [array exists ::arr] && [info exists ::arr(primary)] }
{
set secondary "$::arr(secondary)"
set primary "$::arr(primary)"
if {[LB::status pool $pool member $primary $port] != "up" && [LB::status pool $pool member $secondary $port] == "up"}
{
LB::down pool $poolsec member $primary $portsec
set ::arr(primary) "$secondary"
set ::arr(secondary) "$primary"
}
pool $pool member $::arr(primary)
}
else
{
reject
}
}
when LB_FAILED
{
LB::down
LB::down pool $poolsec member [LB::server addr] $portsec
if { [LB::server addr] == "$::arr(primary)" && [active_members $pool] > 0 }
{
if {[LB::status pool $pool member $::arr(secondary) $port] == "up"}
{
set ::arr(primary) $::arr(secondary)
set ::arr(secondary) [LB::server addr]
pool $pool member $::arr(primary)
}
}
}
- Colin_Walker_12Historic F5 AccountWell, first of all there are a lot of optimizations I would suggest for your iRule to make it more efficient. Setting variables where they aren't absolutely required, using global arrays rather than static:: values (assuming you're on a version that supports them), etc. If you're interested in an optimization discussion, let me know and I'd be happy to help out in that arena.
- Erki_Märks_2779NimbostratusI would only think that i need to use global arrays because i use this data globally - there's at least two of those irules one attached to vhost1, the second irule to the second to vhost2.
- Erki_Märks_2779Nimbostratusany thoughts?
- JRahmAdminI think you could eliminate a lot of complexity by collapsing the two pools into one and attaching a monitor for both ports to the pool. That way, if there's a failure to your node supporting both ports, they both go down.
- Erki_Märks_2779NimbostratusThat's a good idea, but what about the problem that the connections are not dropped, how could i solve this
- JRahmAdminTCP::close should close the connection
- Erki_Märks_2779NimbostratusI know that TCP::close closes the current connection but how could I drop all the connections to both of those vhosts at once. As I said setting pool action on svcdown to drop didn't help me.
- JRahmAdminIf the monitor is marking the pool members down, the connections should be closed automatically. I don't think you can close all connections from an iRule that is only concerned about the current connection, but I could be wrong about that.
- hooleylistCirrostratusIf you have a monitor for both ports associated with the pool member, have action on service down set to reject and either port goes down, LTM should send a reset for any open connections for either port.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects