Forum Discussion
IRULES - LB::reselect
Hello,
I want integrate this irule on my loadbalancer. But you can say me if this irule is totaly correct? Because I dont know how "lb::reselect" will react.
When my request arrive on my node, if my node send 500 error. I want mark this node as down. And i want that this request be sent to another node.
set poolname "TEST"
set fqdn "TEST.com"
set NbNode 2
when HTTP_REQUEST {
if {[HTTP::host] equals $fqdn}
{
pool $poolname
}
}
when HTTP_RESPONSE {
if{([HTTP::status] == 500) or ([HTTP::status] == 404) or ([HTTP::status] == 503)}
{
LB::reselect pool $poolname
if{[active_members $poolname] > $NbNode}
{
LB::down
}
}
}
thank.
- What_Lies_Bene1Cirrostratus
Would it not be better to have a better health monitor rather than this iRule?
- What_Lies_Bene1Cirrostratus
OK, so, you may want to always specify the fqdn as lowercase and also lower what your matching against:
if { [string tolower [HTTP::host]] equals $fqdn }
I'd also reorder your logic as it's possible you'll mark the newly selected node as down:
when HTTP_RESPONSE { if { ([HTTP::status] == 500) or ([HTTP::status] == 404) or ([HTTP::status] == 503) } { if { [active_members $poolname] > $NbNode } { LB::down LB::reselect pool $poolname } else { LB::reselect pool $poolname } } }
I'm pretty sure you could shorten the HTTP::status lookup too but I'm too tired to try.
Also not you don't have any spaces between your if's and the opening brace {.
- Exploitation_CaNimbostratus
ok, thank for your response I will testing.
- Exploitation_CaNimbostratus
I have testing this irule so i have three errors:
What is the probléme, i can't create a variable in a irule? Or its not the right method?
the error:
01070151:3: Rule [/Common/irule_TEST] error: line 1: [command is not valid in the current scope] [set poolname "TEST"] line 2: [command is not valid in the current scope] [set fqdn "TEST.com"] line 3: [command is not valid in the current scope] [set NbNode 2] line 16: [command is not valid in current event context (HTTP_RESPONSE)][LB::reselect pool $poolname]
the script:
set poolname "TEST" set fqdn "TEST.com" set NbNode 2 when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals $fqdn } { pool $poolname } } when HTTP_RESPONSE { if { ([HTTP::status] == 500) or ([HTTP::status] == 404) or ([HTTP::status] == 503) } { if { [active_members $poolname] > $NbNode } { LB::down LB::reselect pool $poolname } else { LB::reselect pool $poolname } } }
- What_Lies_Bene1Cirrostratus
You need to move the set commands to the HTTP_REQUEST event.
- Exploitation_CaNimbostratus
hello,
i can not used command "LB::reselect" in event "HTTP_RESPONSE"? A solution exist?
Thank you
- Exploitation_CaNimbostratus
I seen in devcentral site.
l can do?
when HTTP_REQUEST { set poolname "TEST" set fqdn "TEST.com" set NbNode 2 if { [string tolower [HTTP::host]] equals $fqdn } { set request_headers [HTTP::request] pool $poolname } } when HTTP_RESPONSE { if { ([HTTP::status] == 500) or ([HTTP::status] == 404) or ([HTTP::status] == 503) } { if { [active_members $poolname] > $NbNode } { LB::down HTTP::retry $request_headers } else { HTTP::retry $request_headers } } }
- What_Lies_Bene1CirrostratusThat would work although I don't see the point of LB::down; this functionality should be performed by a monitor.
- Exploitation_CaNimbostratus
hello,
When "lb::down" command is executed. Normaly on "network map" i can see my node is down or no?
Because when my irule is active on my pool.
All request is retry and i haven't error during my load test.
But all node up on "network map". There is no down node
My new code is correcte or no?
when HTTP_REQUEST { set poolname "TEST" set fqdn "TEST.com" if { [string tolower [HTTP::host]] equals $fqdn } { set request_headers [HTTP::request] pool $poolname } } when HTTP_RESPONSE { set currentnode [LB::server addr] set portnumber "80" if { ([HTTP::status] == 500) or ([HTTP::status] == 404) or ([HTTP::status] == 503) } { LB::down pool $poolname member $currentnode $portnumber HTTP::retry $request_headers log "Server $poolname $currentnode $portnumber down!" } }
thank you.
- What_Lies_Bene1Cirrostratus
You are correct. The moment you execute the LB::down command this will trigger a health monitor for that probe and as that will be successful nothing will be marked down in the network map or elsewhere. As I said earlier this functionality should be performed by a monitor.
Recent Discussions
Related Content
* 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