Hi FKnuckles,
I'm a big fan of the Priority Based Activation feature, but unfortunately you can't use this feature for the given requirement (different availability thresholds for failover and failback).
Well, you're code uses just 3 instead of 4 different conditions and looks therefor indeed much cleaner. But on the other hand it does not cover the requirements of the OP and produces a slightly higher overhead. Let me try to compare the different iRules...
Active Operation Scenario
Your code:
if [table lookup $static::flag] eq "backup"
if [active_members $static::pp] >= 1
table set $static::flag "active"
pool $static::pp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup"
if [active_members "$static::primary_pool"] > 1]
pool "$static::primary_pool"
Performance Difference: Your code requires one additional table command execution.
Functional Difference: None
Active Operation Failover Scenario
Your code:
if [table lookup $static::flag] eq "backup"
if [active_members $static::pp] >= 1
table set $static::flag "backup"
pool $static::bp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup"
if [active_members "$static::primary_pool"] > 1]
table add "status_$static::primary_pool" "backup" indefinite indefinite
pool "$static::backup_pool"
Performance Differences: None
Functional Difference: None
Backup Operation Scenario
Your code:
if [table lookup $static::flag] eq "backup"
if [active_members $static::pp] < 1
pool $static::bp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup"
if { [active_members "$static::primary_pool"] >= 4]
pool "$static::backup_pool"
Performance Differences: None
Functional Difference: The OPs requirement is not covered. The requirement for triggering the failback is [active_members $static::pp] = 4 nodes.
Backup Operation Failback Scenario
Your code:
if [table lookup $static::flag] eq "backup"
if [active_members $static::pp] < 1
if [active_members $static::pp] >= 1
table set $static::flag "active"
pool $static::pp
My Code:
if [table lookup "status_$static::primary_pool"] eq "backup"
if { [active_members "$static::primary_pool"] >= 4]
table delete "status_$static::primary_pool"
pool "$static::primary_pool"
Performance Differences: Your code requires one additional [active_members $static::pp] command execution.
Functional Difference: The OPs requirement is not covered.
Cheers, Kai