Forum Discussion
dubdub
Jun 20, 2011Nimbostratus
Just to follow up... finally got this working, this is the final iRule, which is a variation on the excellent ideas suggested in http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/14001/showtab/groupforums/Default.aspx.
when RULE_INIT {
set static::debug 1
}
when CLIENT_ACCEPTED {
if { $static::debug != 0 } {
log local0. "setting addingUser to 1"
}
set addingUser 1
}
when HTTP_REQUEST {
save original request
if { $addingUser == 1 } {
if { $static::debug != 0 } {
log local0. "saving request, redirecting to WebFarm"
}
set req [HTTP::request]
inject lookup URI in place of original request
HTTP::uri "/addDWUser"
set pool to webfarm pool
pool pool_WebFarm
}
}
when HTTP_RESPONSE {
if {$addingUser == 1 } {
collect first response (from lookup server) only
if {[HTTP::header exists Content-Length] && ([HTTP::header Content-Length] < 1048576) } {
set clength [HTTP::header Content-Length]
} else {
set clength 1048576
}
if { $static::debug != 0 } {
log local0. "collecting response presumably from WebFarm, length is $clength"
}
HTTP::collect $clength
}
}
when HTTP_RESPONSE_DATA {
Get poolname from server response
Response would ideally be in the form of a pool name only.
Otherwise parse or derive the poolname here
set myPool pool_DataWarehouse
verify pool exists and has members
if { ![catch [pool $myPool]] }{
if { $static::debug != 0 } {
log local0. "retrying request"
}
pool pool_DataWarehouse
HTTP::retry $req
} else {
insert dead/non-existent pool logic here
}
re-set flag so that subsequent response to re-tried
request from real server is not processed as a lookup
if { $static::debug != 0 } {
log local0. "setting addingUser to 0"
}
set addingUser 0
}
Thanks!
Jen