Forum Discussion
Stevenson_88156
Jan 14, 2011Nimbostratus
RULE_INIT
Hi I am a newbie when it comes to iRULES and when I am reading the about the description for the RULE_INIT event, it says the following: "Triggered when an iRule is added or i...
hooleylist
Dec 12, 2012Cirrostratus
Hi Kevin,
Case 1: Any variable declared in RULE_INIT is global in scope. There would be trampling across RULE_INIT events if the RULE_INIT event set a variable with the same name to different values. The last RULE_INIT to run would set the value.
Case2: Yes and yes.
Case 3: No, global variables and any variable set in RULE_INIT are shared across any virtual server and any connection.
Case 4: No, [virtual name] cannot be run in the RULE_INIT event as it's global in scope and not run in the context of a virtual server or connection.
The other case not discussed yet is that local variables in the same or separate iRules attached to the same virtual server will also overwrite each other.
Basically, if you want to ensure that variables aren't trampled you should name them uniquely across iRules. For example, I no longer use a generic $debug or $static::debug variable. If I did this across all iRules and changed one rule to enable debug, I'd get debug logging enabled on all of them. Instead I create a unique per-iRule debug name like $static::cookie_debug.
Hope this helps,
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects