Forum Discussion

ddurst_21358's avatar
ddurst_21358
Icon for Nimbostratus rankNimbostratus
Jun 27, 2011

f5 Hiccup with new iRule

I am not sure if this belongs in the iRule section or not however I have found no better place to post this issue.

I will do my best to detail the steps that have landed me in my current situation.

 

 

 

1. Had Virtual server with specified pool (pool1) containing 3 nodes (node1,node2,node)

 

2. Removed node3 from pool1 removed node3

 

3. Created new pool image1

 

4. Create new node (image1) this node has same ip as node3 had but a different service port

 

5. Added node to image1 pool

 

 

 

I then created the following rule:

 

 

 

elseif { [HTTP::uri] contains "/image/" } {

 

log local0. "Using: image1 pool"

 

pool image1

 

}

 

 

 

 

 

 

When I visit my sites index page I get a normal response, however when I try to navigate anywhere

 

on the site or hit refresh I get a 404 response that can only becoming from my old node3 on its new

 

service port. I have added a logging rule to confirm my suspicions (it confirms my theory).

 

 

 

when HTTP_RESPONSE {

 

log local0. "Responding node: [IP::server_addr]:[TCP::server_port]"

 

}

 

 

 

 

So I am confused as to how to resolve my current issue without take the following steps.

 

 

 

1. Delete all virtual servers and pools through admin console and re-add.

 

2. Drive to the colocation and hit reset to default button and re-add.

 

 

 

Neither of these options seems appealing and I am hoping there is another method.

 

 

 

Please assist.

 

 

 

 

 

6 Replies

  • I see that you have an "elseif" there in your rule. Could you be matching in an earlier "if" statement in your rule? In a series of if elseif elseif... else statements, you will bail once you get a match.
  • when HTTP_REQUEST {

     

    log local0. "Incoming Request:[IP::client_addr] Requesting: [HTTP::uri]"

     

    if { [HTTP::uri] starts_with "/mrocache/mrosupply_data.xml" } {

     

    log local0. "Using: mrocache pool"

     

    pool mrocache

     

    }

     

    elseif { [HTTP::uri] contains "/image/" } {

     

    log local0. "Using: mroimage pool"

     

    pool mroimage

     

    }

     

    }

     

    when HTTP_RESPONSE {

     

    log local0. "Responding node: [IP::server_addr]:[TCP::server_port]"

     

    }

     

     

    mroimage pool:

     

    10.10.1.3:80

     

    mrocache pool:

     

    10.10.5.1:8080

     

    mrosupply-pool:

     

    10.10.1.1:8080

     

    10.10.1.2:8080
  • So "mrosupply-pool" is the default pool configured for this virtual server? If so, do you get the same behavior if you alter your rule like this?

    
    when HTTP_REQUEST { 
    log local0. "Incoming Request:[IP::client_addr] Requesting: [HTTP::uri]" 
    if { [HTTP::uri] starts_with "/mrocache/mrosupply_data.xml" } { 
      log local0. "Using: mrocache pool" 
      pool mrocache 
     } 
    elseif { [HTTP::uri] contains "/image/" } { 
      log local0. "Using: mroimage pool" 
      pool mroimage 
     }
    else {
      log local0. "Using: mrosupply pool"
      pool mrosupply-pool
     }
    } 
     
  • This worked, however I am curious as to why it worked. Can you please explain so I do not make a similar mistake in the future.
  • Here is an article which explains what you saw:

     

    http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/130/iRules-101--05--Selecting-Pools-Pool-Members-and-Nodes.aspx

     

     

    The short version is that you matched on "/image/" and your next request didn't match on "/mrocache/mrosupply_data.xml". Your rule without that final else statement used the last pool it had selected, the mroimage pool. Adding a final "else" catches anything that didn't match earlier in your rule and ensures that mrosupply-pool is selected if nothing else matches.