Forum Discussion

blwavg_10621's avatar
blwavg_10621
Icon for Nimbostratus rankNimbostratus
Jan 19, 2014

Client Select iRule Failing to Compile

I am trying to have a source address go to a specific member if the node is up, if not then just be sent to the pool. I came up with this but ran into errors. Any ideas?

set $pool test_pool
set $member test_member
when CLIENT_ACCEPTED {
  if { [IP::addr [IP::client_addr] equals 10.10.10.10] } {
     {[LB::status pool $pool members $member]}
      pool default_pool member $member
  } else {
      pool default_pool }
}

ERRORS:

  1. Rule [/Common/Client_select] error: /Common/Client_select:1: error: [command is not valid in the current scope][set $pool test_pool]
  2. /Common/Client_select:2: error: [command is not valid in the current scope][set $member test_member]
  3. /Common/Client_select:5: error: [undefined procedure: [LB::status pool $pool members $member]][{[LB::status pool $pool members $member]}]

3 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    blwavg,

    A couple of pointers. The set command is not quite right and needs to be after an event, so something like

    when CLIENT_ACCEPTED {
      set pool test_pool
      set member test_member
    

    Also, you're checking on a client address but it would be good to check if the pool member is up to. Something like:

    if { ([IP::addr [IP::client_addr] equals 10.10.10.10]) && if { ([LB::status pool $pool member x.x.x.x 80] eq "up") }{
    

    Notice I've added a port here (80) and entered an IP address (x.x.x.x) too.

    Final two things. The member variable you set is fine in itself, however, the way you use it I don't think it will work. It should be an IP address, rather than test_member. You then add a port too to the pool command. An example:

    pool default_pool member x.x.x.x 80
    

    Any reason why you're using default_pool here but set a variable for test_pool?

    Anyway, hope this helps you build a working iRule.

    N

  • I get REALLY close after some tweaking:

    when CLIENT_ACCEPTED {
    set pool test_pool
    if { ([IP::addr [IP::client_addr] equals 10.10.2.20]) && if { ([LB::status pool $pool member 192.168.192.168 443] eq "up") }
          pool $pool member 192.168.192.168 443
       }else { pool $pool 
       }
    }
    

    I still get this error:

    Rule [/Common/Client_select] error: /Common/Client_select:5: error: [parse error: extra characters after close-brace][else { pool $pool}]

    I cannot for the life of me fine the extra character... I will keep trying to fix. I have copied and pasted from note pad and tried manually wiping out any erroneous characters with no luck.

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Try this instead:

     when CLIENT_ACCEPTED {
     set pool test_pool
      if {[IP::addr [IP::client_addr] equals 10.10.2.20]}{
      if {[LB::status pool $pool member 198.168.192.168 443] eq "up"}{      
       pool $pool member 192.168.192.168 443
       } else { 
       pool $pool 
     }
    }    
    }