Forum Discussion
Chris_Phillips
Sep 20, 2006Nimbostratus
check if pool exists
Hi,
any nice way to find if a pool exists? i'm dynamically assigning connections to pools based on the HTTP::host header and want to catch the connection if the pool name doesn't exist. currently the iRule chokes at runtime if i do "pool pool_that_does_not_exist".
Thanks
Chris
- JRahmAdminYou have the answer in your request....use TCL's catch command.
- JRahmAdminHere's an example from deb that you can modify to fit your needs:
when HTTP_REQUEST { set myNode [findstr [HTTP::uri] "node=" 5 "&"] if {[catch {node $myNode}]}{ pool myPool } else { node $myNode } }
- Chris_PhillipsNimbostratussuper. i keep forgetting about making use of real tcl. not that i knew about catch in tcl beforehand anyway.
thanks muchly so.if [ catch { pool "pool_$http_host" } ] { log local0. "ERROR on assiging pool of pool_$http_host" HTTP::respond 200 content "error message here" }
- Chris_PhillipsNimbostratusActually... in your example there you're actually using the node command twice, i assume this isn't actually necessary? i'm only assigning the pool once in my example and it seems to be working.
- JRahmAdminIn the if statement, the node not existing will result in a load balancing decision being made, otherwise (else), it will send the connection to the node. So whereas the node command is used twice, it will only be called once, by the if OR by the else.
- Chris_PhillipsNimbostratussurely not, if the catch(node) command succeeds then the catch() itself is false. therefore the else { node } is excuted, so you will have run the node command twice.
- JRahmAdminDOH! You're right, my bad.
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