Forum Discussion

Fletcher_Cocquy's avatar
Fletcher_Cocquy
Icon for Nimbostratus rankNimbostratus
Sep 27, 2011

iRule to select test pool based on cookie/env variable?

Hi all,

 

we have a virtual server mapping to a pool with one apache web node.

 

client wants to test the new node via the virtual server.

 

 

Can we craft an iRule to direct her session to the new pool/node based on a cookie/env variable she sets beforehand ? (and then reset her session routing back to production after her testing is done?) (I imagine this kind of scheme could also integrate with the app itself so the app say picks up the cookie and announces when its in test mode)

 

 

Can someone please point me at an example of this or suggest a better way to do this with our BigIPs? (BIG-IP 10.2.1 Build 511.0 Hotfix HF3)

 

 

cheers,

 

Fletch

 

http://vmadmin.info

 

 

  • You could add the new member at a lower priority and then use an iRule like this to allow manual selection of it with a query string parameter and cookie:

    http://devcentral.f5.com/wiki/iRules.Select_pool_member_based_on_HTTP_query_string_parameter.ashx

    When you're done testing, change the priority of the new pool member to the same as the other one to have it used in normal load balancing.

    Or as Brian said, if you can filter by client IP, it would be simpler to do something like this:

    
    when CLIENT_ACCEPTED {
    
       if {[IP::addr [IP::client_addr] equals 1.1.1.1]}{
          node 10.1.1.1 80
       }
    }
    

    With this simple iRule you don't even need to add the new member to the pool. When you're done testing, just remove the iRule and add the new member to the pool.

    Aaron
  • Thanks for all the feedback - I am testing the member=[1,2] iRule - (the tester's IP varies) - it seems to work great - EXCEPT

     

    I am having problems with the test node receiving traffic despite being in a lower priority group (1) than the prod node (2).

     

     

    Why would this be?

     

     

    Is there a better way to ensure the test node member never receives traffic unless ?member=2 is specified?

     

     

    thanks
  • Are clients going through a proxy to get to the virtual server? If you take the iRule off, do you see the same issue with pool member selection?

     

     

    Can you try adding a OneConnect profile to the virtual server? if you're using SNAT on the serverside you can use the default OneConnect profile with a /0 source mask. Else, create a custom OneConnect profile with a /32 source mask.

     

     

    Aaron
  • If using OneConnect and the iRule doesn't fix the issue, can you enable debug in the HTTP_REQUEST event and reply with anonymized logs from /var/log/ltm?

     

     

    Thanks, Aaron
  • " If you take the iRule off, do you see the same issue with pool member selection?"

     

     

    NO

     

     

    Looks like a bug in the iRule - I removed the iRule and the Priority Group was perfectly obeyed - as soon as I put it back in, the test node received traffic...(without member=

     

    I tried this 2-3 times and reproduced the issue each time.

     

     

    would be great to get this fixed!

     

     

    thanks

     

  • Can you enable debug on the iRule and reply with the output from /var/log/ltm?

     

     

    Thanks, Aaron