cancel
Showing results for 
Search instead for 
Did you mean: 

iRule to chose persistence profile

SSell
Altostratus
Altostratus

We are running 12.1 and are only using LTM.

We are experiencing an issue with one of our application VS. We have an OnBase load balancing configuration which consists of a Web tier VS and an App tier VS. Our current setup is using a cookie persistence profile and it is working as expected. The OnBase team is rolling out a new feature that uses a Web API that accesses the App VS. The issue we are having is that once the Web API makes a call to the App VS, all following requests must go to the same App server that it was initially load balanced to. With cookie persistence, this is not occurring. We have verified this with logs and captures. We are not able to switch to a source addr persistence as there are only 2 web servers and 5 app servers. We configured a lab environment for testing and did see that a source addr persistence would solve their issue so my question is this. Is it possible to create an iRule that would do the following

If the source IP is 10.10.10.10 then use source_addr

else use OnBase_Cookie

 

I tried something like this (source_addr_vra and OnBase_Cookie are profiles we created), but get errors which I think are just syntax errors (sorry I am very new to scripting)

when CLIENT_ACCEPTED {

if { [IP::addr [IP::client_addr] equals 10.223.13.42] }{

persist source_addr_vra

}

else {

persist OnBase_Cookie

}

}

This is the error I am getting

01070151:3: Rule [/Common/OnBase] error: /Common/OnBase:3: error: ["invalid argument source_addr_vra; expected syntax spec: (add|carp|cookie|delete|dest_addr|hash|lookup|msrdp|none|simple|sip|source_addr|ssl|sticky|uie|universal) "][persist source_addr_vra]

/Common/OnBase:6: error: ["invalid argument OnBase_Cookie; expected syntax spec: (add|carp|cookie|delete|dest_addr|hash|lookup|msrdp|none|simple|sip|source_addr|ssl|sticky|uie|universal) "][persist OnBase_Cookie]

 

 

*EDIT*

I was able to get the iRule to not have any syntax errors with the following

when CLIENT_ACCEPTED {

if { [IP::addr [IP::client_addr] equals 10.223.13.42] }{

persist source_addr source_addr_vra

}

else {

persist cookie insert OnBase_Cookie

}

}

However, the logs fill up with errors

TCL error: /Common/OnBase <CLIENT_ACCEPTED> - bad IP address format (line 2) invoked from within "persist source_addr source_addr_vra"

2 REPLIES 2

cjunior
Nacreous
Nacreous

Hi,

As far as I know, it is not possible to select a persistence profile in iRule or in politics.

Look this:

https://clouddocs.f5.com/api/irules/persist.html

 

To do this, you can set the persistence values ​​from profiles to persist command parameters or create virtual servers for each persistence desired to deal with different origins.

e.g.

 

vs_one_persist_addr:

destination: 10.10.10.10:80

source: 10.223.13.42/32

persist: source_addr_vra

 

vs_two_persist_cookie:

destination: 10.10.10.10:80

source: 0.0.0.0/0

persist: OnBase_Cookie

 

Regards.

Thank you very much for the reply. Based on my research I was thinking I would likely need to have 2 VS to achieve this.