Forum Discussion

sam_kal's avatar
sam_kal
Icon for Altostratus rankAltostratus
Apr 26, 2021

IRule to select IRule doesn't work even if the condition triggers

Problem Statement: Trying to create a I-Rule to forward traffic to a pool "pool-troubleshooting" in case a header is passed in a request, the "if" condition triggers as the logs are part of the loop...
  • jaikumar_f5's avatar
    Apr 26, 2021

    To know what pool was selected, maybe you have lot of pool selection logic or possibly the default may have been selected too, to know what's happening in HTTP_REQUEST, use this,

    when HTTP_REQUEST {
    if { [HTTP::header exists testing] } {
    	log local0. "Pre Pool selected is [findstr [LB::server pool] "" 8 ]"
    	pool pool-troubleshooting
    	foreach aHeader [HTTP::header names] {
    		log local0. "Post Pool selected is [findstr [LB::server pool] "" 8 ]"
    		log local0. "Redirecting to troubleshooting pool HTTP REQUEST HEADER $aHeader: [HTTP::header value $aHeader]"
    	}
    }
    }

    So if you see your intended pool not selected, you can do this,

    when LB_SELECTED {
    if { [LB::server pool] == "/Common/DEFAULT-POOLNAME-443" && [active_members pool-troubleshooting] > 0 } {
    pool pool-troubleshooting
    LB::reselect
    }
    }