Forum Discussion

Sahir_180434's avatar
Sahir_180434
Icon for Nimbostratus rankNimbostratus
Jan 21, 2016

Need help with iRule error log message

Hi all,

 

I am working on upgrading an ltm from 10.2.4 to 11.5.3, all iRules on current 10.2.4 code are working fine but when did the upgrade I got the following error on one of the iRules:

 

Jan 20 02:25:37 ltm-app1 err tmm1[16614]: 01220001:3: TCL error: /Common/ets_80-rule - bad IP address format (line 1)failed to find pool member (line 1) invoked from within "pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"

 

here is the used iRule:

 

when HTTP_RESPONSE {
    if { [HTTP::cookie exists "JSESSIONID"] } {
      set trimID [lindex [split  [HTTP::cookie "JSESSIONID"] "!" ] 0 ]
      if { [session lookup uie $trimID] equals "" } {
        session add uie $trimID [IP::server_addr] 1800
 log local0. "added server entry [session lookup uie $trimID] for jsessionID $trimID "
    } else {
    `
      log local0. "existing server entry [session lookup uie $trimID] for jsessionID $trimID"
 `  }
    }
    `
    }
      when HTTP_REQUEST {
        if { [active_members et-pool] == 0 } {
          HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/unavailable/etServices.html"
        } else {
        if { [HTTP::header exists "X-Forwarded-Host"] } {
          HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
        }
        if { [HTTP::cookie exists "em-et"] } {
 log local0. "Persisting by cookie em-et, contents are [HTTP::cookie "em-et"]"
    `} else {
      if { [findstr [HTTP::uri] "jsessionid" 11 "!"] != ""} {
        pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]
    `

     log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"

    `  } else {
        pool ets_80-pool
    `

     log local0. "No jsession ID, local balancing the connection..."

    
`  }
    }
    }
}

I have little knowledge of iRules, and this rule is not part of my littile knowledge

 

any help to fix the issue ?

 

Thanks.

 

7 Replies

  • Hi Sahir,

    you may try to add an additional debug lines to your iRule to get additional informations. It would help to see whats going on behind the scenes...

    Change...

     

    pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]
    

     

    ... to ...

     

    if { [catch { 
    
        pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"]]
    
    }]} then {
    
        log -noname local0.debug "Extended Error Info: \"[subst \$::errorInfo]\""
        log -noname local0.debug "URI Info: \"[HTTP::uri]\""
        log -noname local0.debug "UIE Info: \"[session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"]]\""
        log -noname local0.debug "Pool Info: \"[members -list ets_80-pool]\""
    
        drop ; We will still terminate the connection since it has thrown an error!
    
    }
    

     

    Note: The change creates an extended error handle. I didn't test the provided code yet, but it should work as before with the difference, that it will log additional information when the error happens again.

    Warning: Please take a look to your LTM log while saving your iRule. If any CMP related warning will raise, then revert the change and come back again. The code is accessing/hacking $::errorInfo to get some additional information... 😉

    Cheers, Kai

     

  • HI Sahir,

     

    I believe I've catched the glitch in your iRule, it seems to be an logic error that would create some havoc when flushing the persistent table (this would happen during migration).

     

    Please repost the entire iRule to get sure. And apply propper formating and syntax highlighting...

     

    Cheers, Kai

     

  • Ok, I have deleted that one and adding the following, let me know if that is what you are looking for?

     

    when HTTP_RESPONSE {
        if { [HTTP::cookie exists "JSESSIONID"] } {
          set trimID [lindex [split  [HTTP::cookie "JSESSIONID"] "!" ] 0 ]
          if { [session lookup uie $trimID] equals "" } {
            session add uie $trimID [IP::server_addr] 1800
            log local0. "added server entry [session lookup uie $trimID] for jsessionID $trimID "
          } else {
            log local0. "existing server entry [session lookup uie $trimID] for jsessionID $trimID"
          }
        }
      }
      when HTTP_REQUEST {
        if { [active_members et-pool] == 0 } {
          HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/unavailable/etServices.html"
        } else {
        if { [HTTP::header exists "X-Forwarded-Host"] } {
          HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
        }
        if { [HTTP::cookie exists "em-et"] } {
            log local0. "Persisting by cookie em-et, contents are [HTTP::cookie "em-et"]"
        } else {
          if { [findstr [HTTP::uri] "jsessionid" 11 "!"] != ""} {
            pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]
            log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
          } else {
            pool ets_80-pool
            log local0. "No jsession ID, local balancing the connection..."
          }
        }
        }
      }
    

     

  • Hi Sahir,

    the problem can be found in this code block...

     

                if { [findstr [HTTP::uri] "jsessionid" 11 "!"] != ""} {
                    pool ets_80-pool member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]
                   log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
                } else {
                    pool ets_80-pool
                   log local0. "No jsession ID, local balancing the connection..."
                }
    

     

    If the client sends an [HTTP::uri] containing the string jsessionid, you'll will use a substring of it to find an matching [session lookup uie] record. But then you don't verify if the session query has deliverd any values before proceeding with the member node selection. I highly doubt this code has ever worked stable...?

    An improved code would look like this...

     

    when HTTP_RESPONSE {
        if { [HTTP::cookie exists "JSESSIONID"] } {
            set trimID [lindex [split  [HTTP::cookie "JSESSIONID"] "!" ] 0 ]
            if { [session lookup uie $trimID] equals "" } {
                session add uie $trimID [IP::server_addr] 1800
               log local0. "added server entry [session lookup uie $trimID] for jsessionID $trimID "
            } else {
               log local0. "existing server entry [session lookup uie $trimID] for jsessionID $trimID"
            }
        }
    }
    
    when HTTP_REQUEST {
        if { [active_members et-pool] == 0 } {
            HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/unavailable/etServices.html"
        } else {
            if { [HTTP::header exists "X-Forwarded-Host"] } {
                HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
            }
            if { [HTTP::cookie exists "em-et"] } {
               log local0. "Persisting by cookie em-et, contents are [HTTP::cookie "em-et"]"
            } else {
                set pool_member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"]]
                if { $pool_member ne "" } {
                    pool ets_80-pool member $pool_member
                   log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
                } else {
                    pool ets_80-pool
                   log local0. "No jsession ID, local balancing the connection..."
                }
            }
        }
    }
    

     

    Note: You may apply the improved code before updating the device...

    Cheers, Kai

  • Kai,

     

    first, Thanks for your effort trying to help on this & you could be right about the rule not being stable. second, as I mentioned before I am an iRules newbie, and have no idea what is this iRule is doing, I was given this project and I am still learning, I am a Cisco guy in first place.

     

    third, I am wondering if you missed an else statement in your suggested code in the following part:

     

     when HTTP_REQUEST {
        if { [active_members et-pool] == 0 } {
            HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/unavailable/etServices.html"
        } else {
            if { [HTTP::header exists "X-Forwarded-Host"] } {
                HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
            }
            if { [HTTP::cookie exists "em-et"] } {
               log local0. "Persisting by cookie em-et, contents are [HTTP::cookie "em-et"]"
            } else {
                set pool_member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"]]
                if { $pool_member ne "" } {
                    pool ets_80-pool member $pool_member
                   log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
                } else {
                    pool ets_80-pool
                   log local0. "No jsession ID, local balancing the connection..."
                }
            }
        }
    }

    and is it should be?

     

    when HTTP_REQUEST {
        if { [active_members et-pool] == 0 } {
            HTTP::redirect "http://[HTTP::header "X-Forwarded-Host"]/unavailable/etServices.html"
        } else {
            if { [HTTP::header exists "X-Forwarded-Host"] } {
                HTTP::header replace "Host" [HTTP::header "X-Forwarded-Host"]
            } else{
            if { [HTTP::cookie exists "em-et"] } {
               log local0. "Persisting by cookie em-et, contents are [HTTP::cookie "em-et"]"
            } else {
                set pool_member [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"]]
                if { $pool_member ne "" } {
                    pool ets_80-pool member $pool_member
                   log local0. "jsessionID [findstr [HTTP::uri] "jsessionid" 11 "!"] sent to [session lookup uie [findstr [HTTP::uri] "jsessionid" 11 "!"] ]"
                } else {
                    pool ets_80-pool
                   log local0. "No jsession ID, local balancing the connection..."
                }
            }
        }
    }

    Thanks.

     

    • Kai_Wilke's avatar
      Kai_Wilke
      Icon for MVP rankMVP
      Hi Sahir, your provided code didn't contain the "else{" on this position. And placing it on this position would make the code structure incomplete. So i highly doubt this needs to be insert... Note: Basically I've just adjusted your iRule formatings to get a better overview. And then changed just the part which throws the error by adding an additional check. Well, it was hard to resist to not optimize additional parts... ;-) BTW: Greetings from a Cisco fellow. I'm sitting right now in front of an C2960XR and applying some boring edge configs... ;-) Cheers, Kai
    • Sahir_180434's avatar
      Sahir_180434
      Icon for Nimbostratus rankNimbostratus
      I am going to try your modified code and see if that is going to solve the issue, will let you know about the result. Thanks.