Forum Discussion
5xx response code error Irule issue
Hi Team,
I have below Irule in place which is working for me based on 503 response but which is restricted to "pool-test_shop.kpr.com_http".
when CLIENT_ACCEPTED { set count 0 }
when HTTP_REQUEST priority 800 { set request [HTTP::request] }
when LB_SELECTED { if { $count >= 1 } { log local0. "Deleting cookie 73686f706c656e6f766f with value \"[HTTP::cookie value 73686f706c656e6f766f]\"" HTTP::cookie remove "73686f706c656e6f766f" LB::reselect pool pool-test_shop.kpr.com_http log local0. "Reselection: member [LB::server addr]:[LB::server port] from pool [LB::server pool]" } }
when HTTP_RESPONSE priority 800 { if { [HTTP::status] eq 503 && $count < 3 && [LB::server pool] == "pool-test_shop.kpr.com_http"} { incr count HTTP::retry $request log local0. "[HTTP::status] from [LB::server addr]:[LB::server port], trying another [LB::server pool] member (retry $count)" } elseif { [HTTP::status] == 503 && $count >= 3 } { HTTP::redirect "http://www.kpr.com" set count 0 log local0. "Redirect to dotcom due to panic mode (retried pool [LB::server pool] $count times)" } elseif { ! ( [HTTP::status] eq 503 ) && $count >= 1 && [LB::server pool] == "pool-test_shop.kpr.com_http" } { set count 0 } elseif { $count >= 1 && ! ( [LB::server pool] == "pool-test_shop.kpr.com_http" ) } { log local0. "Retry count = $count for pool [LB::server pool] -- this connection is being reused" } }
Now we have a external Data-Group which has the below mapping:
"test_shop.kpr.com-VS-HTTP" := "pool-test_shop.kpr.com_http,pool_testprior.levi.com,http://www.kpr.com", "test_shop.kpr.com-VS-HTTPS" := "pool-test_shop.kpr.com_http,pool_testprior.levi.com,http://www.kpr.com",
That means, whenever someone browse a URL, it will fetch the contents based on the matching traffic and subsequently routed the traffic towards mapped Pools whereas www.kpr.com is the fallback host.
Now, we wanted to include 503 response error code for even the application-members marked into Pool: pool_testprior.levi.com. I mean, lets say we have 3 member-servers I in pool_testprior.levi.com, and if one of the member give 503, than it will send the traffic to 2nd member-server and so on. Kindly guide.
Note:
-503 from pool-test_shop.kpr.com_http should NOT have any effect to pool_testprior.levi.com -503 from pool_testprior.levi.com should NOT have any effect to pool-test_shop.kpr.com_http
pool-test_shop.kpr.com_http is for WEC application. -There is session persistence and full application run there
whereas pool_testprior.levi.com is for plain HTTP server -Pages are static, so no persistence is needed -But as there are 3 pool members running, it would be good to have failover there.
Thanks and Regards PZ
9 Replies
I think you should try to make this a bit clearer.
I've rewritten your original rule in a nicer formatting in case someone else understood the initial description:
when CLIENT_ACCEPTED { set count 0 } when HTTP_REQUEST priority 800 { set request [HTTP::request] } when LB_SELECTED { if { $count >= 1 } { log local0. "Deleting cookie 73686f706c656e6f766f with value \"[HTTP::cookie value 73686f706c656e6f766f]\"" HTTP::cookie remove "73686f706c656e6f766f" LB::reselect pool pool-test_shop.kpr.com_http log local0. "Reselection: member [LB::server addr]:[LB::server port] from pool [LB::server pool]" } } when HTTP_RESPONSE priority 800 { if { [HTTP::status] eq 503 && $count < 3 && [LB::server pool] == "pool-test_shop.kpr.com_http"} { incr count HTTP::retry $request log local0. "[HTTP::status] from [LB::server addr]:[LB::server port], trying another [LB::server pool] member (retry $count)" } elseif { [HTTP::status] == 503 && $count >= 3 } { HTTP::redirect "http://www.kpr.com" set count 0 log local0. "Redirect to dotcom due to panic mode (retried pool [LB::server pool] $count times)" } elseif { ! ( [HTTP::status] eq 503 ) && $count >= 1 && [LB::server pool] == "pool-test_shop.kpr.com_http" } { set count 0 } elseif { $count >= 1 && ! ( [LB::server pool] == "pool-test_shop.kpr.com_http" ) } { log local0. "Retry count = $count for pool [LB::server pool] -- this connection is being reused" } }/Patrik
- Parveez_70209
Nimbostratus
Hi Team,
Thanking Patrick for formating my original Irule in a nicer way.
On a continuation of the above Original Irule:
Now we have a external String Data-Group which has the below mapping:
"test_shop.kpr.com-VS-HTTP" := "pool-test_shop.kpr.com_http,pool_testprior.levi.com,http://www.kpr.com", "test_shop.kpr.com-VS-HTTPS" := "pool-test_shop.kpr.com_http,pool_testprior.levi.com,http://www.kpr.com",
That means, whenever someone browse a URL(test_shop.kpr.com), it will fetch the contents based on the matching traffic and subsequently routed the traffic towards mapped Pools(pool-test_shop.kpr.com_http,pool_testprior.levi.com) whereas www.kpr.com is the fallback host.
Now, we wanted to include 503 response error code for even the application-members marked into Pool: pool_testprior.levi.com. I mean, lets say we have 3 member-servers I in pool_testprior.levi.com, and if one of the member give 503, than it will send the traffic to 2nd member-server and so on which should independent of the Cookie. Kindly guide.
I mean the below:
pool-test_shop.kpr.com_http is for WEC application. -There is session persistence and full application run there
whereas pool_testprior.levi.com is for plain HTTP server -Pages are static, so no persistence is needed -But as there are 3 pool members running, it would be good to have fail-over there.
And -503 from pool-test_shop.kpr.com_http should NOT have any effect to pool_testprior.levi.com -503 from pool_testprior.levi.com should NOT have any effect to pool-test_shop.kpr.com_http
Thanks and Regards PZ
I still can't wrap head around this. The "new" description basically looks like a copy of the text above. 🙂
Questions:
You have a data grouplist containing this:
"test_shop.kpr.com-VS-HTTP" := "pool-test_shop.kpr.com_http,pool_testprior.levi.com,http://www.kpr.com" "test_shop.kpr.com-VS-HTTPS" := "pool-test_shop.kpr.com_http,pool_testprior.levi.com,http://www.kpr.com"How do you intend to use the key-value pairs? Do you intend to use the same iRule for two different Virtual Servers and differentiate the results based on the VS name?
If so, I interpret your rule as if you'd use the value in the data grouplist to create an array with "," as the delimiter ("Primary pool, secondary pool, Fallback redirect URL). Is this true?
Irule variables are exclusive to each connection (unless using global variables) so you don't have to be afraid of problemsusing the same rule on the two virtual servers.
As it stands the data group list contains the same value in both cases. What's the point of using it?
/Patrik
- Parveez_70209
Nimbostratus
Hi Patrick,
Ok to be more clear about my intention here.. I have a single Irule itself where I have this IRULE which is currently restricted to pool: pool-test_shop.kpr.com_http only. What its doing basically is checking the 503 error coming from the Internal application-servers from pool-test_shop.kpr.com_http which also deals with Cookie.
Into the same Irule my intention is to include the logic to Pool:pool_testprior.levi.com(pool_testprior.levi.com is for plain HTTP server -Pages are static, so no persistence is needed -But as there are 3 pool members running, it would be good to have fail-over there.) also,but that should not be related to Cookie operation specified under LB_SELECTED.
So, basically even a single 503 when its comes from pool-test_shop.kpr.com_http, it will jump to 2nd application-server and so on.
Thanks and Regards PZ
Sorry, I still don't understand your question. Perhaps someone else does. :)
Try to answer my questions above. It might help interpreting your plan a bit.
/Patrik
- Parveez_70209
Nimbostratus
Hi Patrick,
You can ignore the mapping part for your below response: I just specified to let you know the whole architecture.
How do you intend to use the key-value pairs? Do you intend to use the same iRule for two different Virtual Servers and differentiate the results based on the VS name?
For now Irule is applied to one VS only.
What I need here how to include additional logic into the exiting Irule:
1.Need to include 503 logic to pool_testprior.levi.com, but thats independent of Cookie Logic mentioned under Event: when LB_SELECTED
Thanks and Regards Parveez
If all that differs is that particular event, then why don't you just make a rule without the LB_SELECTED?
/Patrik
- Parveez_70209
Nimbostratus
Hi Patrick,
As I mentioned pool-test_shop.kpr.com_http is dependent on Cookie Persistence while pool_testprior.levi.com should not impact Operation related to pool-test_shop.kpr.com_http, as its cookie independent.
But logic related to pool-test_shop.kpr.com_http will be the same.
For example: Let's say:
-
If we have three active-members into the Pool:pool-test_shop.kpr.com_http and let's say incase a single 503 error comes from Ist member-server, it will reselect the 2nd member-server and so on, and incase all the three members from pool-test_shop.kpr.com_http throw 503 error, it should redirect to http://www.kpr.com.
-
The only difference into the logic between pool-test_shop.kpr.com_http and pool-test_shop.kpr.com_http, is that pool-test_shop.kpr.com_http will not impact the Cookie operation and reselection part.
Hope now it is a bit clear. Sorry, for creating confusion.
Thanks and Regards Parveez
-
Hi Parveez
Since you want to run all events except LB_SELECTED when the pool is pool_testprior.levi.com I guess you can test for the two before running the logic in HTTP_RESPONSE.
Then you can do something similar in the LB_SELECTED event.
Please note that "LB::reselect pool pool-test_shop.kpr.com_http" was changed to just LB::reselect and that there's no guarantee that it will choose unique servers on all attempts as it used the load balancing method.
Try this one?
when CLIENT_ACCEPTED { set count 0 } when HTTP_REQUEST priority 800 { set request [HTTP::request] } when LB_SELECTED { if { $count >= 1 } { if { [LB::server pool] != "pool_testprior.levi.com" } { log local0. "Deleting cookie 73686f706c656e6f766f with value \"[HTTP::cookie value 73686f706c656e6f766f]\"" HTTP::cookie remove "73686f706c656e6f766f" } LB::reselect log local0. "Reselection: member [LB::server addr]:[LB::server port] from pool [LB::server pool]" } } when HTTP_RESPONSE priority 800 { if { [LB::server pool] == "pool-test_shop.kpr.com_http" || [LB::server pool] == "pool_testprior.levi.com" } { if { [HTTP::status] eq 503 && $count < 3 } { incr count HTTP::retry $request log local0. "[HTTP::status] from [LB::server addr]:[LB::server port], trying another [LB::server pool] member (retry $count)" } elseif { [HTTP::status] == 503 && $count >= 3 } { HTTP::redirect "http://www.kpr.com" set count 0 log local0. "Redirect to dotcom due to panic mode (retried pool [LB::server pool] $count times)" } elseif { ! ( [HTTP::status] eq 503 ) && $count >= 1 } { set count 0 } elseif { $count >= 1 } { log local0. "Retry count = $count for pool [LB::server pool] -- this connection is being reused" } } }/Patrik
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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