Forum Discussion

jaikumar_f5_226's avatar
jaikumar_f5_226
Icon for Nimbostratus rankNimbostratus
Apr 18, 2017

Source Persistence Irule with custom error response on pool member down

Hi Folks,

I'm trying to make a setup where the requirement is to send the traffic to the same server until the source persistence gets expired. If for some reason the selected server is down, the ltm has to respond with a custom error. I dont want the ltm to load balance to another member in the pool.

My setup has 2 pool members (A & B). When http request made, I could see persistence entry to A.

When I take down the A server, my request gets loadbalanced to B automatically which I dont want to happen. I'm testing this with the below Irule on a default IIS server page. I guess thats why there's no persistence table being retained, since the existing connections gets closed once the http request is fulfilled (Action-on-service down is set to default (none) - So existing connections alone would have retained, but here no existing connection entry seen) Should I be testing this on a real connection retaining setup instead of the default IIS page.

Also the LB_FAILED event doesn't seem to be triggered when the A server went down. Its getting triggered when the entire pool (A & B) goes down, what event should I be using here. Please advise.

when CLIENT_ACCEPTED {
    if { [persist lookup source_addr [IP::client_addr]] eq "" } {
        persist source_addr [IP::client_addr]
    }
}
when HTTP_REQUEST {
    log local0. "HTTP Request Event."
    set httprequest [HTTP::request]
}
when LB_SELECTED {
    log local0. "LB Selected Event [LB::server addr] : [LB::server port]"
}
when LB_FAILED {
    log local0. "LB Failed Event [LB::server addr] : [LB::server port]"
    LB::down
    persist none
    HTTP::respond 500 content {
      
         
            500 Error
         
         
            We are sorry, but the site you are looking for is temporarily out of service
         
      
   }
}

Update - 5th May : Went through Dev Wiki, got Persist_Down event,

when CLIENT_ACCEPTED {
    if { [persist lookup source_addr [IP::client_addr]] ne "" } {
        log local0. "xxx Persistent Event Triggered for ClientIP [IP::client_addr]"
    }
}

when LB_SELECTED {
    log local0. "xxx LB Selected Event [LB::server addr] : [LB::server port]"
}
when LB_FAILED {
    log local0. "xxx LB Failed Event [LB::server addr] : [LB::server port]"
    LB::down
    persist none
    HTTP::respond 500 content {
      
         
            500 Error
         
         
            We are sorry, but the site you are looking for is temporarily out of service
         
      
   }
}
when PERSIST_DOWN {
    log local0. "xxx Persist down Event [LB::server addr] : [LB::server port]"
    LB::down
    persist none
    HTTP::respond 500 content {
      
         
            500 Error
         
         
            We are sorry, but the site you are looking for is temporarily out of service
         
      
   }
}

I see on the Irule statistics, Persist Down Event is triggered. But I dint see the 500 error page in browser... Can some one please test my Irule and confirm it works for persistent sessions.

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    PERSIST_DOWN seems to be the right event for this. LB_FAILED won't be triggered if there are other pool members available.

     

    Did the browser actually get the 500 error? You might want to catch the HTTP headers you receive on your browser. The response is missing "Content-Type".