Forum Discussion

DFeike_160744's avatar
DFeike_160744
Icon for Nimbostratus rankNimbostratus
Feb 24, 2015

irule Troubleshooting:

Hi guys,

once i try to assign the following irule to a VS i receive this error message: 01070151:3: Rule [/Common/rule_errorpage_test] error: Unable to find pool (sorry_pool) referenced at line 21: [pool sorry_pool]

    when RULE_INIT {
    set static::sorry_pool "/Common/pool_wwbtest_sorry"
    set static::wartung_pool "/Common/pool_wwbtest_wartung" 
}

when HTTP_REQUEST {
log local0. "Incoming URI = [HTTP::uri]"
    if { [catch { [active_members [LB::server pool]] < 1}] } {

            if { [catch {active_members $static::wartung_pool}] > 0 } {
                    pool wartung_pool
                    set mypick [LB::select]
                    log local0. "The LB choice is: $mypick"
                    set newuri [string map {/wartung.html/ /} [HTTP::uri]]
                    log local0. "The new URI is = $newuri"
                    HTTP::uri $newuri
                    eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                    log local0. "[HTTP::uri] [LB::server addr]" 

                } elseif { [catch {active_members $static::sorry_pool}] > 0 } {
                    pool sorry_pool
                    set mypick [LB::select]
                    log local0. "The LB choice is: $mypick"
                    set newuri [string map {/sorry.html/ /} [HTTP::uri]]
                    log local0. "The new URI is = $newuri"
                    HTTP::uri $newuri
                    eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                    log local0. "[HTTP::uri] [LB::server addr]" 
                            } else {
                            HTTP::respond 200 content "Lieber Kunde,\r\ndie Seite befindet sich aktuell in der Wartung.\r\n\r\nDear Customer,\r\nthis site is down for maintenance. We are sorry for the inconvience.\r\n" noserver connection close
        }                   
    }
}

i am really puzzled and clueless what the problem might be. If you have any ideas to solve this i would be grateful 🙂

best regards David

  • Anesh's avatar
    Anesh
    Icon for Cirrostratus rankCirrostratus

    has this pool been created ""/Common/pool_wwbtest_sorry"

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    David,

    Shouldn't it be the following:

    pool $static::sorry_pool

    As sorry_pool is a static, global variable?

    Same for wartung_pool too.

    Hope this helps,

    N

  • Hi,

     

    setting the variable as suggested by nathan did the trick, however i have another problem. although the default pool of the VS was available, the irule did trigger all the time and the http response in the else clause was delivered.

     

    Is there anything wrong with the catch query?

     

    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      Do you need to use the "catch" command? does it work without?
    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      I'm not convinced it's needed here...could be wrong though.
  • honestly i have no clue as what the catch command does, since i am a TCL newbie. My colleague removed the catch commands, but currently the device isn't happy with the syntax and won't save it. Once i had another go with the modification, I'll write an update.

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    try this:

     when RULE_INIT {
        set static::sorry_pool "/Common/pool_wwbtest_sorry"
        set static::wartung_pool "/Common/pool_wwbtest_wartung" 
    }
    
    when HTTP_REQUEST {
    log local0. "Incoming URI = [HTTP::uri]"
        if { [active_members [LB::server pool]] < 1 } {
    
                if { [active_members $static::wartung_pool] > 0 } {
                        pool wartung_pool
                        set mypick [LB::select]
                        log local0. "The LB choice is: $mypick"
                        set newuri [string map {/wartung.html/ /} [HTTP::uri]]
                        log local0. "The new URI is = $newuri"
                        HTTP::uri $newuri
                        eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                        log local0. "[HTTP::uri] [LB::server addr]" 
    
                    } elseif { [active_members $static::sorry_pool] > 0 } {
                        pool sorry_pool
                        set mypick [LB::select]
                        log local0. "The LB choice is: $mypick"
                        set newuri [string map {/sorry.html/ /} [HTTP::uri]]
                        log local0. "The new URI is = $newuri"
                        HTTP::uri $newuri
                        eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                        log local0. "[HTTP::uri] [LB::server addr]" 
                                } else {
                                HTTP::respond 200 content "Lieber Kunde,\r\ndie Seite befindet sich aktuell in der Wartung.\r\n\r\nDear Customer,\r\nthis site is down for maintenance. We are sorry for the inconvience.\r\n" noserver connection close
            }                   
        }
    }
    
  • Hi Nathan, thanks for your suggestion. We are currently working with this:

    when CLIENT_ACCEPTED {
       set def_pool [LB::server pool]
       log local0. "def_pool is [LB::server pool]"
    }
    
    when HTTP_REQUEST {
    log local0. "Incoming URI = [HTTP::uri]"
        if { [active_members [LB::server pool]] < 1 } {
    
                if { [active_members pool_wwbtest_wartung] > 0 } {
                        set members [active_members -list pool_wwbtest_wartung]
                        log local0. "Active members in pool_wwbtest_wartung are: $members"
                        set mypick [LB::select]
                        log local0. "The LB choice is: $mypick"
                        set newuri [string map {/wartung.html/ /} [HTTP::uri]]
                        log local0. "The new URI is = $newuri"
                        HTTP::uri $newuri
                        eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                        log local0. "[HTTP::uri] [LB::server addr]" 
                        pool pool_wwbtest_wartung
    
                    } elseif { [active_members pool_wwbtest_sorry] > 0 } {
                        set members [active_members -list pool_wwbtest_sorry]
                        log local0. "Active members in pool_wwbtest_sorry are: $members"
                        pool pool_wwbtest_sorry
                        set mypick [LB::select]
                        log local0. "The LB choice is: $mypick"
                        set newuri [string map {/sorry.html/ /} [HTTP::uri]]
                        log local0. "The new URI is = $newuri"
                        HTTP::uri $newuri
                        eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                        log local0. "[HTTP::uri] [LB::server addr]" 
                        } else {
                    HTTP::respond 200 content "Lieber Kunde,\r\ndie Seite befindet sich aktuell in der Wartung.\r\n\r\nDear Customer,\r\nthis site is down for maintenance. We are sorry for the inconvience.\r\n" noserver connection close
            }                   
        }
    }
    

    We've disabled members from the default pool and brought up 2 Members in the pool_wwbtest_wartung. the irule triggered correctly jumping in the "if" part, but then failed with this log message:

    Feb 26 08:46:45 f5 info tmm[16796]: Rule /Common/rule_wwbtest_error_pages : Incoming URI = /

    Feb 26 08:46:45 f5 info tmm[16796]: Rule /Common/rule_wwbtest_error_pages : Active members in pool_wwbtest_wartung are: {xxx.xxx.xxx.x 1080} {yyy.yyy.yyy.y 1080}

    Feb 26 08:46:45 f5 err tmm[16796]: 01220001:3: TCL error: /Common/rule_wwbtest_error_pages - Prerequisite operation not in progress (line 7) (line 7) invoked from within "LB::select"

    Do you have another idea what might be the problem? 🙂

  • ok, assigned to pool to get the LB select working...next problem: building the request:

     

    Feb 26 15:52:11 f5 info tmm3[16796]: Rule /Common/rule_wwbtest_error_pages : Incoming URI = /

     

    Feb 26 15:52:11 f5 info tmm3[16796]: Rule /Common/rule_wwbtest_error_pages : Active members in pool_wwbtest_wartung are: {xxx.xxx.xxx.xxx 1080} {yyy.yyy.yyy.yyy 1080}

     

    Feb 26 15:52:11 f5 info tmm3[16796]: Rule /Common/rule_wwbtest_error_pages : The LB choice is: pool /Common/pool_wwbtest_wartung member yyy.yyy.yyy.yyy 1080

     

    Feb 26 15:52:11 f5 info tmm3[16796]: Rule /Common/rule_wwbtest_error_pages : The new URI is = /

     

    Feb 26 15:52:11 f5 err tmm3[16796]: 01220001:3: TCL error: /Common/rule_wwbtest_error_pages - invalid command name "GET" while executing "GET HTTP/1.1 " ("eval" body line 1) invoked from within "eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n""

     

    troubleshooting is nearly complete :)

     

    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      GET is not a irule command, that's why you're getting the error. You'd need something like HTTP::respond, as an example. to be honest i think it is a redundant line. you're already sending the connection to the new pool member (mypick) with the URI modified. In any case the Host part of this comand won't work as the mypick variable is "pool /Common/pool_wwbtest_wartung member yyy.yyy.yyy.yyy 1080" not a FQDN as you would normally see if a Host Header.
  • for test purposes i simplified this part

    log local0. "The LB choice is: $mypick"
                        set newuri [string map {/sorry.html/ /} [HTTP::uri]]
                        log local0. "The new URI is = $newuri"
                        HTTP::uri $newuri
                        eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
                        log local0. "The LB choice is: $mypick"
                        set newuri [string map {/sorry.html/ /} [HTTP::uri]]
                        log local0. "The new URI is = $newuri"
                        HTTP::uri $newuri
                        eval "GET [HTTP::uri $newuri] HTTP/1.1\r\nHost: $mypick\r\n\r\n"
    

    to the following:

    HTTP::uri "/wartung.html"
    log local0. "[HTTP::uri] [LB::server addr]"
    

    this had the effect, that the desired page was indeed delivered to the client, however additional graphics, would not be delivered due to the hardcoded request to the server. Is there an easy way to solve this problem with a redirect or what could be a good way get the additional content delivered?

    here are the logs from the rule: Incoming URI = /Fehlerseite/wartungsarbeiten/logo_mit_claim.jpg Active members in pool_wwbtest_sorry are: {xxx.xxx.xxx.xxx 1080} The LB choice is: pool /Common/pool_wwbtest_sorry member xxx.xxx.xxx.xxx 1080 /sorry.html

  • just for information we fixed the problem with a uri check to verify, if the client wants to load additional content for the page or if it is the first request to get the maintenance page.

    if { [active_members pool_wartung] > 0 } {
    
                        switch -glob [string tolower [HTTP::uri]] {
                        "/directory/*"  {   
                                pool pool_wartung
                                }
                        default {
    
                                pool pool_wartung   
                                HTTP::uri "/wartung.html"
                            }
                        }
    
    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      Good stuff, thanks for feeding this back to the community. Glad you got it sorted.