In what order do Actions run; how do I change the order?
Short answer
Actions run in the order of the Actions field in the vService form, from top to bottom; On Request actions are evaluated among themselves in this order at the request stage, and On Response actions at the response stage. The order is changed by dragging the action cards in the Actions field or by rewriting the list order in WEB-CLI. Redirect to HTTPS, Advanced CAPTCHA and Traffic Mirroring take effect after the other request actions regardless of their position in the list.
Problem: The Order of the Actions Changes the Result
In TR7, Conditions & Actions (similar to F5 Local Traffic Policy / iRules, Citrix Responder / Rewrite policy) are applied one after another on a vService. If an action blocks or redirects the request, the subsequent request actions do not run for that request; an action that writes a variable must also come before the action that reads it. For this reason, the order in which the actions run needs to be known and changed when necessary.
Exceptions to the Order
| Action | Where it runs |
|---|---|
| Redirect to HTTPS | After all request actions; a Block further down prevents it |
| Advanced CAPTCHA | After all request actions, while the request is being forwarded to the Backend Service |
| Traffic Mirroring | After the request has passed through all request actions; an action that terminates the request also prevents the copy |
| Advanced Traffic Inspection, Quarantine | The monitoring (counting) part is done at the start of the request; the blocking, redirect or content display part of Quarantine runs at its position in the list |
| Manual Action | Where it runs is determined by the Manual rule field and Manual rule priority fields of the action |
Solution: Two Methods
| Your situation | Suitable method |
|---|---|
| From the interface | Method 1: Drag and drop in the Actions field |
| From the command line | Method 2: Writing the list order with WEB-CLI |
Method 1: Drag and Drop in the Actions Field Recommended
- How it works The order of the cards in the Actions field is the execution order; a card is moved by dropping it onto another card.
- Where it is opened vService → Edit → Details → Actions · Left Monitor Panel → vService → Load Balancer Management → Actions → Edit
- Requirement At least two actions on the vService
- vService type HTTP · L7 TCP
Step-by-Step Configuration
On the Load Balancer → Load Balancer vService List screen, the vService is selected and Edit is clicked; the Actions field in the Details section is reached. The same field is also opened with the Edit link in the header of the Actions section in the Load Balancer Management tab of the vService; this window shows only the Actions field.
The action card is dragged and dropped onto another card. A card dragged down is placed right below the target card, and a card dragged up is placed right above the target card. To move an action to the end, it is also enough to remove the card with × and select it again from the list; the reselected card is added to the end of the list.
The vService is saved with Save.
Verification
The order of the actions is seen in the Actions section in the Load Balancer Management tab of the vService.
New orderMethod 2: Writing the List Order with WEB-CLI
- How it works The action list of the vService is kept in order in the
rulesfield;--rules.Nputs the written action in place of the action at that position. All the positions that will swap are written in the same command. - Where it is opened TR7 WEB-CLI →
lb service show·lb service update - Requirement WEB-CLI access
- vService type HTTP · L7 TCP
Step-by-Step Configuration
In the vService record, the actions are listed in order; the topmost action is 0 (lb service).
lb service show <vService>For each position that changes, the action that should be at that position is written; positions that are not written remain as they are. Example: to swap the first two actions (previously 0 = action-A, 1 = action-B):
lb service update id <vService> --rules.0 <action-B> --rules.1 <action-A>Verification
The order is checked again in the lb service show output or in the Actions section in the Load Balancer Management tab of the vService.
action-B, action-A, …Common Mistakes
- Turning the Actions option in Details off and on. When the Actions module is turned off in the vService form, the action list is cleared completely; the actions need to be added again.
- Moving Redirect to HTTPS to the top and expecting it to run first. Redirect to HTTPS and Advanced CAPTCHA take effect after the other request actions; a Block further down in the list prevents them.
- Assuming request and response actions form a single order. On request actions are ordered among themselves at the request stage, and On response actions at the response stage; even if they are mixed in the same list, they do not wait for each other.
- Placing the action that reads a variable before the action that writes it. A value written with Set Variable on Hit or Create Traffic Variable is used in the actions that come later in the list.
- Writing only the moved action in WEB-CLI. If
--rules.0 <action-B>is written on its own, the command is rejected because action-B would appear twice in the list; all the positions that swap are written in the same command.
How it is done in the documentation
