Forum Discussion

Sean_McGirk_859's avatar
Sean_McGirk_859
Icon for Nimbostratus rankNimbostratus
Jul 26, 2018

Need help with iRule using custom persistence table based on GUID

I have an iRule which is mostly functional however, the persistence does not seem to be working as needed. The collection of the GUID data is working as needed. My logs show that the correct node (node1) is selected but a packet capture reveals that node2 is in fact chosen instead. I have two questions. 1. Is there some way to view a custom persistence table? 2. Does the "when LB_SELECTED" look right?

 

2 Replies

  • Here is the iRule

     

    when RULE_INIT { set static::persist_duration 300 set static::debug_TCPPersist 1 ^^^^ set to zero to stop logging }

     

    when CLIENT_ACCEPTED { TCP::collect 200 }

     

    when CLIENT_DATA { set sTCP_Data [TCP::payload 200] set sGUID [string trim [getfield [getfield $sTCP_Data ":" 2] "," 1] " \""] set sNodeIP [table lookup -subtable TCP_Persist $sGUID] if { $sNodeIP eq "" } { if { $static::debug_TCPPersist} { log local0. "Moving on to load balance decision for guid $sGUID" } } else { if { $static::debug_TCPPersist} { log local0. "We found a previous decision for $sGUID to node $sNodeIP" } } TCP::release

     

    }

     

    when LB_SELECTED { if { $sNodeIP eq "" } { table set -subtable TCP_Persist $sGUID [LB::server addr] $static::persist_duration if { $static::debug_TCPPersist} { log local0. "Set persist for $sGUID to [LB::server addr]" } } else { node $sNodeIP if { $static::debug_TCPPersist } { log local0. "Selected $sNodeIP" } } }