Forum Discussion

SP_266134's avatar
SP_266134
Icon for Nimbostratus rankNimbostratus
Apr 11, 2018

Time based iRule to take off one node offline

I have VS and two nodes in the pool. I want to write an Irule so that at 1.00 AM each day one node will be taken off the pool and don’t want the traffic to do load balancing. During this 1 hr or 2 hrs. the node will be rebuilding indexes. I want to use that to build index on the other server form 3-4 am. Found these links below. Are there another ways to solve this problem? Is this the best way. How do I take node offline force offline?

 

when RULE_INIT {

 

Start of indexing window in YYYY-mm-dd HH:MM format set static::start_date_node1 "2018-04-12 01:00" End of maintenance window in YYYY-mm-dd HH:MM format set static::end_date_node1 "2018-04-12 02:00" Start of indexing window in YYYY-mm-dd HH:MM format set static::start_date_node2 "2018-04-12 01:00” End of maintenance window in YYYY-mm-dd HH:MM format set static::end_date_Node2 "2018-04-12 02:00"

 

Convert start/end times to seconds from the epoch for easier date comparisons set static::startNode1 [clock scan $static::start_date_node1] set static::endNode1 [clock scan $static::end_date_node1] set static::startNode2 [clock scan $static::start_date_node2] set static::endNode2 [clock scan $static::end_date_node2] }

 

when CLIENT_ACCEPTED {

 

Get the current time in seconds since the Unix epoch of 0-0-1970 set now [clock seconds] Check if the current time is between the start and end times if {$now > $static::startNode1 and $now < $static::endNode1}{ Take forceofline Node1 }

 

if {$now > $static::startNode2 and $now < $static::endNode2}{ Take forceofline Node2 }

 

}

 

Links 1.https://devcentral.f5.com/questions/irule-to-block-access-of-vs-on-specific-days 2.https://devcentral.f5.com/questions/time-based-irule-question-49613comment39127 3.https://devcentral.f5.com/codeshare?sid=716&lc=1

 

1 Reply

  • Hello,

    Try this:

    when HTTP_REQUEST {
    
    set start_date "02:00"
    set end_date "04:00"
    set server "1.2.3.4"
    set port "443"
    
    set start [clock scan $start_date]
    set static::end [clock scan $end_date]
    set now [clock seconds]
    
    if {$now > $start and $now < $end}{
        LB::down pool SOMEPOOL member $server $port
    }
    
    }
    

    Additionnal information you can use Stanislas Irule for determine time, day, ...:

    https://devcentral.f5.com/questions/irule-to-block-access-of-vs-on-specific-days

    Most important is this command "LB::down pool poolname member address port"

    https://devcentral.f5.com/Wiki/Default.aspx?Page=LB__down&NS=iRules

    For information LB::down allow you to prevent that your request will be send to specific pool member for eache request done. And when your maitenance periode will be finished, health of this poolmember will be up on the next health check...