Forum Discussion
EBL_27513
Apr 30, 2012Nimbostratus
Assistance Requested - iRule causes virtual to hang upon LTM reboot
Hello,
I'm a relative newbie when it comes to writing iRules, and so wanted to see if anyone in the forum would have some time to help me with an issue I'm having. Any help would be much ap...
Hi EBL,
If you want to use this as a generic iRule then you might want to try something like this:
when HTTP_REQUEST {
Check active servers. If there are none, redirect to Maintenance Page
if { [active_members [LB::server pool]] == 0 } {
Clear any request page before routing traffic to new pool.
This will keep the requested [HTTP::host] value but reset the [HTTP::uri].
HTTP::uri /
pool maintenance-hub
}
}
when LB_FAILED {
Catch pending requests / any failures and nullify their Persistence
Then Redirect back to the base site for handling
persist none
HTTP::redirect "/"
}
This will check the the number of active members in the Default Pool [LB::server pool. If the results are 0 then change the URI to the root of the website (HTTP::uri /) hosted in the target pool (maintenance-hub).
For any requests that were in flight the LB_FAILED will capture them, nullify the persistence and Redirect the requestor to the base of the site.
I did not use the LB::reselect becuse it would attempt to select another member of the same pool and if there are none you might get a long hang and then a failure rather than some immediate action.
You may want to put even more thought into the LB_FAILED Event. If your site is operating normally and then takes some type of hit (say one server crashes), you wouldn't want those users to be sent to a maintenance page if there are still other servers that could service them.
I would suggest keeping the first portion of the HTTP_REQUEST that checks the active_members and handles the user when all of the servers are down (most likely on purpose for maintenance) and handle the in flight requests by adding the "Action On Service Down" option to "Reselect" on the pools to handle any server failures.
Hope this helps.
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