Forum Discussion

Erika_I_Garner's avatar
Erika_I_Garner
Icon for Altostratus rankAltostratus
Feb 09, 2018

Default action in iRule is not being triggered. Help!

I am having some issues with the following irule, it works great when the cookie is present, however if the request does not have a cookie it gives me the log as if it already did have a cookie.

I should be seen the log " "[IP::client_addr]--cookie [HTTP::cookie value cookiecrisp] No Cookie Present - Go to default Pool" if the request doesnt have a cookie. Would you all be able to tell what am I doing wrong?

when HTTP_REQUEST {

if { [HTTP::cookie exists cookiecrisp] } { 

    switch [HTTP::cookie value cookiecrisp] { 

        "901" { if { [LB::status pool P----QA-443 member  10.0.9.130 443] eq "up" } {

            pool P----QA-443 member 10.0.9.130 443

            log local0. "[HTTP::cookie value cookiecrisp] matched NODE S-S1Q to cookie 901" 

            } elseif { 

                [LB::status pool P----QA-443 member  10.0.11.131 443] eq "up" } {

                pool P----QA-443 member 10.0.11.131 443  

                log local0. "[HTTP::cookie value cookiecrisp] NODE S-S1Q DOWN, sent to NODE S-S2Q " 

            } else {

                    pool P----QA-443

                    log local0. "[HTTP::cookie value cookiecrisp] NODE S-S2Q DOWN, sent to the pool 
                    P----QA-443"

                    }
                }

        "902" { if { [LB::status pool P----QA-443 member 10.0.11.131 443] eq "up" } {


            pool P----QA-443 member 10.0.11.131 443

            log local0. "[HTTP::cookie value cookiecrisp] matched NODE S-S2Q to cookie 902" 

            } elseif { 

                [LB::status pool P----QA-443 member 10.0.9.132 443] eq "up" } {

                pool P----QA-443 member 10.0.9.132 443  

                log local0. "[HTTP::cookie value cookiecrisp] NODE S-S2Q DOWN, sent to NODE S-S3Q " 

            } else {

                    pool P----QA-443

                    log local0. "[HTTP::cookie value cookiecrisp] NODE S-S3Q DOWN, sent to the pool P----QA-443"


                    }
                }


        "903" { if { [LB::status pool P----QA-443 member 10.0.9.132  443] eq "up" } {

            pool P----QA-443 member 10.0.9.132 443

            log local0. "[HTTP::cookie value cookiecrisp] matched NODE S-S3Q to cookie 903" 

            } elseif { 

                [LB::status pool P----QA-443 member 10.0.9.130  443] eq "up" } {

                pool P----QA-443 member 10.0.9.130 443  

                log local0. "[HTTP::cookie value cookiecrisp] NODE S-S3Q DOWN, sent to NODE S-S1Q " 

            } else { 

     pool P----QA-443 

                     log local0. "[HTTP::cookie value cookiecrisp] NODE S-S3Q DOWN, sent to the pool P----QA-443"

                    } 

                }

            default { 

            pool P----QA-443 

            log local0. "[IP::client_addr]--cookie [HTTP::cookie value cookiecrisp] No Cookie Present - 
            Go to default Pool" 
        }               


    } 

}

}

Thank you for your help! -Erika

2 Replies

  • before the switch, you have this condition:

    if { [HTTP::cookie exists cookiecrisp] } { 
    

    if the cookie is not present, you can't go to the default statement.

  • Ok this look better

    when HTTP_REQUEST {

    pool P----QA-443

    log local0. "[IP::client_addr] No Cookie Present - Go to default Pool"

          switch [HTTP::cookie value cookiecrisp] { 
    
            "901" { if { [LB::status pool P----QA-443 member  10.0.9.130 443] eq "up" } {
    
                pool P----QA-443 member 10.0.9.130 443
    
                log local0. "[HTTP::cookie value cookiecrisp] matched NODE S-S1Q to cookie 901" 
    
                } elseif { 
    
                    [LB::status pool P----QA-443 member  10.0.11.131 443] eq "up" } {
    
                    pool P----QA-443 member 10.0.11.131 443  
    
                    log local0. "[HTTP::cookie value cookiecrisp] NODE S-S1Q DOWN, sent to NODE S-S2Q " 
    
                } else {
    
                        pool P----QA-443
    
                        log local0. "[HTTP::cookie value cookiecrisp] NODE S-S2Q DOWN, sent to the pool P----QA-443"
    
                        }
    
                    }
    
            "902" { if { [LB::status pool P----QA-443 member 10.0.11.131 443] eq "up" } {
    
                pool P----QA-443 member 10.0.11.131 443
    
                log local0. "[HTTP::cookie value cookiecrisp] matched NODE S-S2Q to cookie 902" 
    
                } elseif { 
    
                    [LB::status pool P----QA-443 member 10.0.9.132 443] eq "up" } {
    
                    pool P----QA-443 member 10.0.9.132 443  
    
                    log local0. "[HTTP::cookie value cookiecrisp] NODE S-S2Q DOWN, sent to NODE S-S3Q " 
    
                } else {
    
                        pool P----QA-443
    
                        log local0. "[HTTP::cookie value cookiecrisp] NODE S-S3Q DOWN, sent to the pool P----QA-443"
    
                        }
    
                    }
    
            "903" { if { [LB::status pool P----QA-443 member 10.0.9.132  443] eq "up" } {
    
                pool P----QA-443 member 10.0.9.132 443
    
                log local0. "[HTTP::cookie value cookiecrisp] matched NODE S-S3Q to cookie 903" 
    
                } elseif { 
    
                    [LB::status pool P----QA-443 member 10.0.9.130  443] eq "up" } {
    
                    pool P----QA-443 member 10.0.9.130 443  
    
                    log local0. "[HTTP::cookie value cookiecrisp] NODE S-S3Q DOWN, sent to NODE S-S1Q " 
    
                } else { 
    
                        pool P----QA-443 
    
                         log local0. "[HTTP::cookie value cookiecrisp] NODE S-S3Q DOWN, sent to the pool P----QA-443"
    
                        } 
    
                    }
    
            }    
    

    }