Forum Discussion
hoolio
Cirrostratus
Oct 21, 2009CMP compatible global writable data structures / adding an array to the session table?
I'm trying to port a 9.x iRule to 10 and have it CMP compatible. The gist of the rule logic is, for a set list of URIs, track the number of unanswered requests and ensure it stays under a configured limit. In the 9.x iRule, I had a datagroup with two fields:
uri_tokenmax_unanswered_requests
--------------------------------
/uri11000
/uri2500
In the 9.x iRule, I'd store each URI token and a corresponding count of current unanswered requests in a global array. I used a global array as the data needed to be readable and writable across all TCP connections.
In 10.x with CMP, I cannot reference any global variables. I can't modify the contents of a datagroup from an iRule so that's not an option. I can't count the number of session table entries. And I can't seem to store an array as a session table value.
Does anyone have any ideas on this? If so, I'd be happy to hear about them. If not, I'll open an RFE case with F5 Support.
For reference, here is a simple test for trying to add an array to a session table entry (which doesn't work):
when HTTP_REQUEST {
array set myarray {
key1 value1
key2 value2
}
if {[array exists myarray]}{
log local0. "\$myarray is an array with key/values: [array get myarray]"
} else {
log local0. "\$myarray is not an array: $myarray"
}
This causes a runtime TCL error:
can't read "myarray": variable is array while executing "session add uie myarray $myarray"
if {[catch {session add uie mykey1 $myarray} result]}{
log local0. "session add error: $result"
}
session add uie mykey2 [array get myarray]
set myvalue1 [session lookup uie mykey1]
if {[array exists myvalue1]}{
log local0. "\$myvalue1 is an array with key/values: [array get myvalue1]"
} else {
log local0. "\$myvalue1 is not an array: $myvalue1 (llength: [llength $myvalue1])"
}
set myvalue2 [session lookup uie mykey2]
if {[array exists myvalue2]}{
log local0. "\$myvalue2 is an array with key/values: [array get myvalue2]"
} else {
log local0. "\$myvalue2 is not an array: $myvalue2 (llength: [llength $myvalue2])"
}
}
And the log output:
: $myarray is an array with key/values: key1 value1 key2 value2
: session add error: can't read "myarray": variable is array
: $myvalue1 is not an array: (llength: 0)
: $myvalue2 is not an array: key1 value1 key2 value2 (llength: 4)
Thanks,
Aaron
- hoolio
Cirrostratus
Hi Colin, - hoolio
Cirrostratus
Yep... it should work quite nicely for this scenario.
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