Forum Discussion
Bret_McGinnis_1
Nimbostratus
Sep 20, 2005TCL runtime errors
Hi, is there a way to capture and process iRule TCL runtime errors. On a few occasions I have created and tested an iRule and in our lab and it works fine. When I implement the iRule on a production BigIP it fails because I am trying to use a variable that does not exist. Or worse, it works on the active BigIP and fails on the standby when it becomes the active BigIP.
When an iRule fails because of a TCL erro the packet is dropped. It that the normal? can it be changed?
Global variables make this more difficult.
Regards,
- unRuleY_95363Historic F5 AccountFirst, yes it's normal that a TCL error causes the connection to be reset. Unfortunately, there really isn't another way to continue with the connection once the rule event returns an error.
when HTTP_REQUEST { if { [catch { if { ... } { foo } else { bar } } myresult] != 0 } { log local0. "My rule failed: $myresult" } }
- Bret_McGinnis_1
Nimbostratus
Hi, - unRuleY_95363Historic F5 AccountThere is also "string is integer" which will return a boolean if the string contains a valid integer. You can also add -strict to make the empty string also return false. This does check for underflow and overflow integers.
- Bret_McGinnis_1
Nimbostratus
This is good stuff. For the mod 12 calculation I will try the -strict option. - Bret_McGinnis_1
Nimbostratus
Oh, I forgot to ask. If I "catch" the error do I lose the syslog message with the TCL error indicating what the problem was? - unRuleY_95363Historic F5 AccountThat seems reasonable, however, you should be able to put more explicit checks around the area that the error is occuring. Maybe you can elaborate more on the error and we can help get to the bottom of that.
- Bret_McGinnis_1
Nimbostratus
Sorry to go radio silent for so long but writting iRules is not my day job. - unRuleY_95363Historic F5 AccountThe mod 12 calculation works fine up until the number is larger than 9 digits. After 9 it fails the integer check. -strict has no effect.Hmm, I'm not sure what's going on here other than Tcl may not be properly handling mod on what it calls "wide integers" (64-bit integers). I'll try to look into it. In the meantime, you could try using the binary command to break the "wide integer" into two regular 32-bit integers and then do the appropriate math on the combination of those.
- Bret_McGinnis_1
Nimbostratus
I'm back. The only outstanding issue on this thread is the TCL error when I terminate iRule processing using "return" while within a "catch". At the end of the catch I check the RC and if it is != 0 I send a log message with the error. - unRuleY_95363Historic F5 AccountChange it to only log the error if catch returns 1.
If you re-read the above parts of this post, you'll see that catch actually returns 2 if a return statement is encountered.if { [catch { ... } lb_selected] == 1 } { log local0.error "iRule captured TCL error: $lb_selected" }
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