Forum Discussion
Mathieu_Mathieu
Nimbostratus
Jan 04, 2007LB::reselect'ing the same node
Hello everyone,
I'm trying to write an iRule to redirect HTTP requests from a failed server to a working one.
I wrote the following simple piece of code for testing purpose: replay client request when the selected node responds with a 503 status code.
My main problem is that sometime, the LB::reselect method is reselecting the same node again and again (but the other node was not tagged as down by monitors).
Is there a simple way to be sure to switch to a different node ?
when CLIENT_ACCEPTED {
set i 0
}
when HTTP_REQUEST {
set request [HTTP::request]
}
when LB_SELECTED {
if { ($i > 0) } {
LB::reselect
log local0. "next target is [LB::server addr]"
}
}
when HTTP_RESPONSE {
if { ([HTTP::status] == 503) } {
log local0. "Error code 503 from [LB::server addr]."
incr i
if { ($i < 3) } {
log local0. "Replaying client request."
HTTP::retry $request
} else {
log local0. "Too many errors from peers, giving up."
}
}
}
Results in:
Rule XXX HTTP_RESPONSE: Error code 503 from 10.1.1.1.
Rule XXX HTTP_RESPONSE: Replaying client request.
Rule XXX LB_SELECTED: next target is 10.1.1.1
Rule XXX LB_SELECTED: next target is 10.1.1.1
Rule XXX HTTP_RESPONSE: Error code 503 from 10.1.1.1.
Rule XXX HTTP_RESPONSE: Replaying client request.
Rule XXX LB_SELECTED: next target is 10.1.1.1
Rule XXX LB_SELECTED: next target is 10.1.1.1
Rule XXX HTTP_RESPONSE: Error code 503 from 10.1.1.1.
Rule XXX HTTP_RESPONSE: Too many errors from peers, giving up.
Thanks for your help.
- Colin_Walker_12Historic F5 AccountInteresting. Well, the LB::reselect command is only going to perform another LB decision, the same way it would occur if a new request were to hit the BIG-IP. Perhaps there's something in your configuration that's sending the request to this particular node? What load balancing mechanism are you using?
- Deb_Allen_18Historic F5 AccountI thought I remembered something awhile back posted in this forum indicating that an LB::detach might be required to force a true re-selection since the node is already selected & responding?
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