This section discusses the various errors and troubleshooting options available on NSX Advanced Load Balancer.
DataScripts may fail in one of the following two ways:
Configuration Error
All DataScripts are parsed during configuration save/edit. Incorrect DataScript syntax will fail when attempting to commit the DataScript. The configuration time error is reported as an aid in debugging and will catch syntax errors, not logic errors. The following DataScript has extra characters. Lua
interprets this as a variable that has not yet been declared, such as abc = 1.
if avi.vs.client_ip() == "10.1.1.1" then abc avi.http.close_conn() def end ghi
Error message:
Failed to compile the datascript "Drop_Client_on_http_req.ds": luac: Drop_Client_on_http_req.ds:3: '=' expected near 'avi'
The rule above has three syntax errors, but only the first error encountered will be reported. In this example, abc is an undeclared variable, but the determination is noticed until reading the next line. Hence, the error is reported on line 3, not line 2: http_req.ds:3
and the error location is reported near 'avi
'. DataScripts are very tolerant of spaces and carriage returns. The variable declaration abc = 2 is valid.
abc = 2
The following DataScript is missing an end to complete the if logic:
if avi.vs.client_ip() == "10.1.1.1" then avi.http.close_conn()
Error message:
Failed to compile the datascript "Drop_Client_on_http_req.ds": luac: Drop_Client_on_http_req.ds:1: 'end' expected near '<eof>'
Execution Error
Even though a DataScript may be saved without error, it may still have logic or other issues that may pop up later. When a DataScript execution encounters a failure, the script execution ends prematurely for that request or response. An HTTP 500 Internal Server Error
is sent to the client, and a client log is generated with the stack trace of the prematurely ended script to aid debugging.
Use the following
filter to search for clients with a DataScript error.significance= “Request ended abnormally: Datascript failed to execute”
. Open a client log and click All Headers to see more info about the error.
The following is an example of an error from the logs:
Datascript Error
[string "Drop Client"]:2: attempt to call field 'close_conn' (a nil value)
Datascript Error Stack Trace
stack traceback: coroutine 0: [string "Drop Client"]:2: in function <[string "Drop Client"]:1>
The stack trace for this error may not provide the reason, but it does give a useful hint. The error is in line two of the rule“Drop Client”]:2 and has something to do with the close_conn function. The issue may still not be immediately obvious looking at the rule.
if avi.vs.client_ip() == "10.1.1.1" then avi.close_conn() end
For more information, see avi.http.close_conn. After changing the function to the correct name, test and validate that the issue is resolved.
In the above example, most clients would not be impacted by the broken rule. This same logic can be used to isolate an issue and test without impacting other users.