LB::Server pool empty

I need to switch between two different pools, based on availables members. I found several answers and test this one:

when RULE_INIT {
    set static::BACKUP_POOL "/Partition/Backup_Pool"
}
when HTTP_REQUEST {
    set default_pool [LB::server pool]

    if { [active_members $default_pool] < 1 } {
            pool $static::BACKUP_POOL
    else {
            pool $default_pool
        }    
    }
}

However, LB::server pool always returns an empty string.

I am on version 11.4.1

Do you have a default pool in the virtual server?

Also, you don’t need to use the LB::server pool, if you use a default pool in the virtual server. A simplified iRule would be:

when RULE_INIT {
    set static::BACKUP_POOL "/Partition/Backup_Pool"
}
when HTTP_REQUEST {
    if { [active_members $default_pool] < 1 } {
            pool $static::BACKUP_POOL
    }
}