Forum Discussion

Susheel_308346's avatar
Susheel_308346
Icon for Nimbostratus rankNimbostratus
Jul 24, 2017

Schedule Maintenance Page For Impacted Application

Hello, We use a Virtual server which will route traffic to 50 different pools based on the http request. we achieve this with policy. We have a sensitive application which brings the whole system down if they have issues. I would like to enable maintenance page for that impacted application on our F5 if that host is not responding for an x amount of time (example : 404 for 10 minutes or higher response time for requests not being processed to back-end) and need to remove that maintenance page or make the members available for that pool once the response times are back to normal. I don't know if I can achieve this by disabling the members as the statistics cannot be counted.

 

Will an iRule work ? If yes, could someone help me on how to achieve this?

 

7 Replies

  • Susheel,

     

    To understand more, is it possible for you to share your configuration. Are using irule to distribut connections to different pools or your using policies. Irule should be possible considering what policy and your using and for which pool you want to use maintenance page.

     

  • Hello Habib,

     

    Thank you for your response. Our F5 Version :: BIG-IP 12.0.0 Build 1.14.628 Engineering Hotfix HF1.

     

    We are using Policy attached to one Virtual Server and forwarding requests to different pools based on the http-host request.

     

  • Yes, this can be achieved using an iRule, but you'll want to be quite clear about the conditions that can trigger this. The very high-level logic is this:

     

    when HTTP_RESPONSE {
        if {  } {
                set condition_started_at [table lookup condition]
            
                if { $condition_started_at eq "" } {
                    table set condition [clock seconds] indef indef
                }
                else {
                    if { [clock seconds] > $condition_started_at } {
                        HTTP::respond 200 contents {
                           
                        }
                    }
                }
            }
            else {
                table delete condition
            }
        }
    }
    

     

    I haven't tested this, since it's just psuedo-code. For the HTTP::respond you may consider using an iFile, as has been suggested in other posts.

    You should be aware that both the table calls and the clock calls are fairly costly. There is an alternative form that uses static:: variables and a Tcl Associative Array, but that means each tmm will compute the condition independently. That might be okay for you, and it is considerably cheaper/faster than using table.

    • Susheel_308346's avatar
      Susheel_308346
      Icon for Nimbostratus rankNimbostratus

      Vernon, Thank you for your response. When application request us to take them offline to avoid impacting response time for other apps in our shared environment. We force offline their application which will show 404 to end users, can we put an iRule to show end users a maintenance page instead of 404 only specific to that pool.

       

    • VernonWells's avatar
      VernonWells
      Icon for Employee rankEmployee

      Yes. The solution above does that. The snippet:

       

      HTTP::respond 200 contents { ... }
      

       

      responds with a 200 (OK) and with the contents between the braces (presumably the HTML of your maintenance page). Once again, using an iFile to store your maintenance page usually makes more sense.

       

    • Susheel_308346's avatar
      Susheel_308346
      Icon for Nimbostratus rankNimbostratus

      Thank you for your response. I'm trying to add if it matches for a specific URI like /abc. I want to display 404. I tried using HTTP::uri but I got a failure that it should be used in HTTP::Request.

       

      when HTTP_RESPONSE { if { ( [HTTP::status] == 404 ) } { log local0. "Maintenance Page Enabled" HTTP::respond 200 content [ifile get "maintenance"] } }

       

  • The Request-URI is a function of an HTTP Request, so it has no meaning in the context of a response. If you use the HTTP::respond, there will be no HTTP_RESPONSE event (since the BIG-IP responds directly).

    So, when you match a specific URI Request Path, do you want to respond with a 200 or a 404? I assume 200 with a maintenance page. In that case:

     

    when HTTP_REQUEST {
        switch -glob [HTTP::path] {
            "/foo/bar/*" -
            "/here/there/foo.html" {
                HTTP::respond 200 content { maintenanceWe're working. }
            }
        }
    }
    

     

    This would provide that maintenance page for any URI request path starting with "/foo/bar/" or the absolute path "/here/there/foo.html". You should use an iFile for the actual maintenance page, and a Data Group (class) for the matching URI paths.