Forum Discussion
Chad_Roberts_21
Nimbostratus
Jun 14, 2006Pools and Persistence
I'm having a persistence issue with an iRule I am testing on a site that will be partially inaccessible on holidays. The code below is part of an experiment to find the syntax that will make this work. Note that this assumes that there is a group list containing holiday dates in a mm/dd/yy format.
when HTTP_REQUEST timing on {
if { ([HTTP::uri] starts_with "/sc/") } {
set current_date [clock format [clock seconds] -format {%D} ]
if {([matchclass $current_date equals $::Holidays ] )} {
HTTP::uri "/offhour.html"
log "Blocked for holiday"
persist none
pool after_hour_pool
}
else {
log "Access to SC allowed"
}
}
}
By itself, it appears to work great... if you open a browser and go to https://my.domain.com you can connect at any time, and if you open a browser from scratch and type https://my.domain.com/sc/ (and the day's date is matched as a holiday) the uri is rewritten correctly and your traffic is forwarded to a different pool, so you receive a page that says the site is unavailable.
However, the problem is this: if you open a browser, go straight to the restricted page, receive the after hours error, and then immediately try to go to https://my.domain.com/ without closing and reopening the browser, the traffic continues to be sent to the pool for the server that contains only the error page. I thought the inclusion of "persist none" would resolve the issue, but it has not helped. Any ideas?
8 Replies
Sort By
- unRuleY_95363Historic F5 AccountYou need an outer else clause for when the HTTP::uri does not start_with "/sc/" that resets the pool to the default pool:
Persistence has more to do with subsequent connections than with subsequent requests within the same keep-alive connection. The connection to the server is kept open until the pool selection actually changes (or OneConnect is configured).when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { if { [HTTP::uri] starts_with "/sc/" } { ... } else { pool $default_pool } }
- Chad_Roberts_21
Nimbostratus
I hear what you're saying, but I'm afraid it didn't affect my problem. I updated the code as you recommended:when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST timing on { if { ([HTTP::uri] starts_with "/sc/") } { set current_date [clock format [clock seconds] -format {%D} ] if {([matchclass $current_date equals $::Holidays ] )} { HTTP::uri "/offhour.html" log "Blocked for holiday" persist none pool after_hour_pool } else { pool $default_pool log "Access to SC allowed" } } }
- unRuleY_95363Historic F5 AccountYou need it one more level out as well.
- Chad_Roberts_21
Nimbostratus
I meant to mention that I thought that might be what you meant but that I tried that too. Actually, when you just bump it one level back, it negates the pool command from within the if statement.when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST timing on { pool $default_pool if { ([HTTP::uri] starts_with "/sc/") } { set current_date [clock format [clock seconds] -format {%D} ] if {([matchclass $current_date equals $::Holidays ] )} { HTTP::uri "/offhour.html" log "Blocked for holiday" persist none pool after_hour_pool } else { log "Access to SC allowed" } } }
- Deb_Allen_18Historic F5 AccountDoesn't the "pool" command load balance the request to that pool immediately?
- Chad_Roberts_21
Nimbostratus
That's what I thought too before this experiment, but as I mentioned before when I put one pool command within an if statement and then another after the if statement concludes, the second one overwrites it every time. When I rewrote it so that I started off with a pool command that only confirmed what the virtual server already had defined and then included another one within the if statement, the second one took over when the conditions were met, otherwise all new traffic (even within the same keep-alive session) used the default pool. - unRuleY_95363Historic F5 AccountNo, the pool command only "sets" the pool to use.
- Deb_Allen_18Historic F5 AccountWow, that's really good to know.
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