Forum Discussion
Brian_69413
Nimbostratus
Jun 14, 2012Default pool in a switch statement
We have a Virtual Server that is assigned a default pool and also an iRule that applies a different pool given a certain path. We believe this was working fine as an if statement, but was recently changed to a switch statement. We started to receive reports that traffic not matching one of the cases(I.e. hitting the default). We're still ending up at the secondary pool. A pool statement in the default case fixed this, but was wondering why this would be necessary. Also, is it different from an IF statement, or was it just a coincidence?
I assumed that these non-matching cases would look to the VIP config for pool info.
2 Replies
- hoolio
Cirrostratus
Hi Brian,
Did you have an else clause in the if statement? If so, you were assigning a pool in all cases in the iRule. If you didn't have an else clause, I'd guess it was just coincidence that you noticed the issue after changing to a switch statement.
I think it's most intuitive if you use an iRule to assign a pool in some cases to do it in all cases. If you want to reference the VS default pool, you can save the name in CLIENT_ACCEPTED:when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { switch -glob [HTTP::path] { "/app1*" { pool pool_app1 } "/app2*" { pool pool_app2 } default { pool $default_pool } } }
Or if you want to avoid specifying the pool in each iRule condition, you could add a OneConnect profile to the virtual server. If you're using SNAT, you can use the default OneConnect profile with a /0 source mask. Else, create a custom /32 source mask OneConnect profile and add that to the virtual server.
Aaron - Brian_69413
Nimbostratus
Thanks, that is helpful info. The reason I was down this path is because one case has a redirect, one just changes the path and the other assigns a new pool. I will take your advice and modify all cases to include the default pool.
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
