Forum Discussion
The same static variable in different iRules/VS
Hi,
I have a static variable set in iRule named rule-http:
when RULE_INIT {
set static::variable "first_value"
}
This iRule rule-http is applied to virtual server VS-1 (1.2.3.4:80) - used in production very often
I prepared second iRule named rule-http-new, with the same variable name set to a different value:
when RULE_INIT {
set static::variable "second_value"
}
and applied it to VS-2 (1.2.3.5:80) - it will be used in the future, now only tested couple of times, not processing much data
I assumed that when client request hits VS-1, rule-http is processed and regardless of the previous value, the static::variable is set to "first_value". And that the last set value will remain in the system until next change or reload. Or Am I wrong? Because in real, the value of static::variable remains set to "second_value" and other events of the iRule rule-http are not processed as expected.
ver. 17.5.1.3
Thank you for clarification.
Hello Pytonius
static variables might became very trickySo first of irule init does not execute on a request base but every time the irule is initiated (saved, applied, etc)
That said if the last action you did was in second irule, that variable preserved
3 Replies
Hello Pytonius
static variables might became very trickySo first of irule init does not execute on a request base but every time the irule is initiated (saved, applied, etc)
That said if the last action you did was in second irule, that variable preserved- Pytonius
Altostratus
OK, that is interesting. So the most deterministic approach is to have only 1 iRule in whole system with RULE_INIT for static variable definitions (maybe not applied in any VS) and all other iRules just referencing those variables without the ambitions to change any of them. So I rather stay with local variables :-)
Thank you again, Injeyan!
Hi Pytonius,
if they are really static and you need to access them from different iRules, why not store them in a datagroup?
KR
Daniel
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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