Forum Discussion
iRule to disable a node when health check fail
Okay, completely untested in the real world, but perhaps something like this:
-
Create two identical pools (same members) and apply your monitor(s) to only one of them - the "status" pool.
-
Apply a generic cookie profile to your VIP and this iRule:
when RULE_INIT { user-defined: debug enable/disable set static::lb_debug 1 user-defined: application pool name set static::app_pool "lb_test_pool" user-defined: status pool name set static::status_pool "lb_test_status_pool" } when LB_SELECTED { if { $static::lb_debug } { log local0. "Selected: [LB::server]" } if { [LB::status pool $static::status_pool member [LB::server addr] [LB::server port]] eq "down" } { if { $static::lb_debug } { log local0. "Status pool node down - reselecting" } LB::reselect pool $static::status_pool } } when HTTP_RESPONSE { if { [HTTP::cookie exists "BIGipServer$static::status_pool"] } { if { $static::lb_debug } { log local0. "Rewriting persistence cookie" } set persistval [HTTP::cookie value "BIGipServer$static::status_pool"] HTTP::cookie remove "BIGipServer$static::status_pool" HTTP::cookie insert name "BIGipServer$static::app_pool" value $persistval } }
Change the name of the static::app_pool and static::status_pool variables to the names of your application and status pools, respectively.
So you have two pools: one applied to the VIP and another exactly identical pool with your health monitor(s) applied. On LB_SELECTED, if a) there's no existing persistence and b) the chosen member from the primary pool is marked "down" in the status pool, reselect a new (known good) node from the status pool. LTM will send a persistence cookie for the status pool and node, which you'll rewrite to re-attach persistence to the app pool.
Also note that this iRule does not account for complete mid-session node failures, but it may roll over gracefully.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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