Forum Discussion

APT-Productions's avatar
APT-Productions
Icon for Nimbostratus rankNimbostratus
Sep 03, 2015

how to select a different virtual server's current pool?

We're working up websocket support and sending websocket connection attempts to a specific application pool.

  • www VIP uses pool www_default (usually).
  • app VIP uses pool app_default (usually).

The following iRule is applied to our 'www' vip:

when CLIENT_ACCEPTED {
  HTTP::enable
}
when HTTP_REQUEST {
  if {[HTTP::header value "Upgrade"] equals "websocket"} {
    if { ( [class match [HTTP::uri] starts_with WebSocketUris ] ) } {
      pool app_default
      HTTP::disable
      return
    }
  }
}

That works great. It skips apache behind the www pool (with either no or bleeding edge support for websockets so no thanks) and sends directly to the apps.

However...

The problem is the statically defined 'app_default' pool. When we need to update the nodes behind app_default, we'll change the virtual server 'app' to use 'app_shunt'.

So... how can I have an iRule on the 'www' vip send traffic to the pool currently set on the 'app' vip? Or get the name of the pool currently in use on the 'app' vip from an irule on the 'www' vip (which would lead directly to setting the pool).

I'm completely flummoxed.

Thanks, chris

3 Replies

  • Hi,

    you could stick this in the irule (add in your other logic as needed)...This will check if the app_default has any active members if not use the shunt pool. So come upgrade time you just disable the app_default pool members. You could also apply this on the app VS.

    if {[active_members app_default] >= 1}{
      pool app_default
      } else {
      pool app_shunt
      }
    

    Another way without using separate pools is to create priority groups within the app_default pool, add the app_default servers in the higher priority group and the shunt ones in the other. In a steady state keep the shunt ones disabled/offline and when it's maintenence time enable the shunt pool members and disable the default pool members and drain the connections off as needed...

    cheers

  • I have an idea, but don't know if it's possible or how to execute on it. If we could set a global variable (e.g.: ::app_pool) automatically via an iRule on the app vip - which is triggered whenever the pool is changed - I could then simply use that global var above and be done.

     

    Is this possible?

     

  • Well, we ended up going with this solution:

    iRule activated on app VIP:

    when LB_SELECTED {
      set static::app_current_pool [LB::server pool]
    }
    

    Every time a pool member is selected for the a connection through the VIP, the global var 'app_current_pool' is set to the pool name.

    The final iRule on the web VIP:

    when CLIENT_ACCEPTED {
      HTTP::enable
    }
    when HTTP_REQUEST {
      if {[HTTP::header value "Upgrade"] equals "websocket"} {
        if { ( [class match [HTTP::uri] starts_with WebSocketUris ] ) } {
          if { [info exists "static::app_current_pool"] } {
            pool $static::app_current_pool
          else
            pool app_default
          }
          HTTP::disable
          return
        }
      }
    }
    

    Major change here is if the var exists, use it's value. Otherwise, run with default.

    This has been tested and works.