Forum Discussion

Leav97's avatar
Leav97
Icon for Altocumulus rankAltocumulus
Aug 14, 2019
Solved

iRule to verify node is member of pool and passing the pools health check

I have an irule that uses a table to determine which node a client should use. I'd like to have the rule double check the node is passing health checks and is a member of a pool. Just as a precaution in case pool members have changed. The existing rule is pretty basic. But, I haven't found any examples online to help me build out more error prevention.

 

when CLIENT_ACCEPTED {

 if { [table lookup tbltest[TCP::local_port]] ne "" } {

  node [table lookup tbltest[TCP::local_port]]

 }

}

 

  • when SERVER_CONNECTED {  

     set TargetNode [table lookup tbltst[TCP::local_port]]

       set ActiveNode [active_members -list test-pool]

     

    if {$TargetNode eq "" } {

       return

       }

    if {$ActiveNode contains $TargetNode } {

       node $TargetNode

     }

    }

3 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    How is this table updated, and why isn't a health monitor good enough?

    • Leav97's avatar
      Leav97
      Icon for Altocumulus rankAltocumulus

      when SERVER_CONNECTED {

       table set "tbltest[TCP::remote_port]" [IP::remote_addr] indefinite

      }

       

      If there is already an entry from the last successful connection, the rule skips the health monitor on the pool. I'd like the rule to double check that the server is healthy and in the pool.

  • when SERVER_CONNECTED {  

     set TargetNode [table lookup tbltst[TCP::local_port]]

       set ActiveNode [active_members -list test-pool]

     

    if {$TargetNode eq "" } {

       return

       }

    if {$ActiveNode contains $TargetNode } {

       node $TargetNode

     }

    }