Forum Discussion
Festus_50639
Nimbostratus
Dec 01, 2008"Select pool based on uri content" iRule doesn't seem to be working
Good morning,
I have an iRule that is designed to select a pool based on a string found in the uri and it doesn't seem to be working. I have a log that collects the uri for reference. The "test" rule I have in place that searches the uri and creates the "destination pool name" seems to be creating the pool name correctly, but when I put the "action" rule into place the http request hangs. Background and iRules are provided below.
Background:
-The VIP is listening on port 80 and has a default pool listening on 8981
-The web application being load balanced is Tibco ESB
-There are 25 separate services that are supported by this application and all are listening on different ports
-Individual pools are created with basic http monitor showing all pool members as "up"
-Our pools have a naming convention that has a string before and after the service name. (i.e. esb__pool)
-Use of "uri" and "test" rules yield the following log entries:
Dec 1 08:37:28 tmm tmm[1097]: Rule esb_pool-uri-log : ====VIP uri request is /eProxy/service/CreditCardService?wsdl====
Dec 1 08:37:28 tmm tmm[1097]: Rule esb_pool-mgr_test : ==ESB Tibco: Requested pool name is esb_CreditCardService_pool==
-Use of the "uri" and "action rules yield the following log entries:
ec 1 08:43:36 tmm tmm[1097]: Rule esb_pool-uri-log : ====VIP uri request is /eProxy/service/CreditCardService?wsdl====
Dec 1 08:43:36 tmm tmm[1097]: Rule esb_pool-mgr_action : ==ESB Tibco: Requested pool name is esb_CreditCardService_pool==
iRules:
"uri logging rule"
rule esb_pool-uri-log {
when HTTP_REQUEST {
set esb_uri [HTTP::uri]
log local0. "===="
log local0. "====VIP uri request is $esb_uri===="
}
}
++++++++++++++++++++++++++
"pool selection test rule"
rule esb_pool-mgr_test {
when HTTP_REQUEST {
set front "esb_"
set back "_pool"
set svc_uri [getfield [HTTP::uri] ? 1]
set svc_name [getfield $svc_uri "dir1/service/" 2]
set pool_name [concat $front$svc_name$back]
log local0. "==ESB Tibco: Requested pool name is $pool_name=="
}
}
++++++++++++++++++++++++++
"pool selection action rule"
rule esb_pool-mgr_action {
when HTTP_REQUEST {
set front "esb_"
set back "_pool"
set svc_uri [getfield [HTTP::uri] ? 1]
set svc_name [getfield $svc_uri "dir1/service/" 2]
set pool_name [concat $front$svc_name$back]
log local0. "==ESB Tibco: Requested pool name is $pool_name=="
if { [catch { pool $pool_name } ] } {
log local0. "====ERROR: Attempting to assign traffic to non-existant pool $pool_name===="
log local0. "====Sending traffic to default esb pool===="
pool esb_8981_pool
}
}
}
Is there something I am missing that is not sending the traffic to the correct pool?
Thanks,
Kevin
- Colin_Walker_12Historic F5 AccountKevin,
- Festus_50639
Nimbostratus
Colin, thanks for the sanity check and reply. - hoolio
Cirrostratus
Hi Kevin, - Festus_50639
Nimbostratus
Aaron, - hoolio
Cirrostratus
Hi Kevin,when HTTP_REQUEST { pool $esb_8981_pool set sel_node [LB::server name] set front "esb_" set back "_pool" set svc_name [getfield $svc_uri "eProxy/service/" 2] set svc_pool [concat $front$svc_name$back] foreach line $::esb_svc_name_port_class { if {[string match [getfield $line ":" 1] $svc_name] } { set svc_name_port [getfield $line ":" 2] } } } when LB_SELECTED { if { ([LB::status pool [LB::server pool] member [LB::server addr] [LB::server port]] eq "up")\ and ([LB::status pool $svc_pool member [LB::server addr] $svc_name_port] eq "up") } { eval $sel_node } else { LB::reselect } }
- Festus_50639
Nimbostratus
Thanks Aaron, - hoolio
Cirrostratus
I'm not sure why that would happen. Can you add a log statement to verify that both checks are evaluating to true? - Festus_50639
Nimbostratus
After re-reading the documentation on LB::select and LB::server I realized I should have been using "LB::server" which is now working properly. I have since conducted functional testing on the iRule and monitor configuration and have found that they are functioning as expected. - hoolio
Cirrostratus
Out of curiosity, could you post your final rule? I'm curious to see what you ended up with. - Festus_50639
Nimbostratus
Here is the current final draft on my rule.
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