From 2dbe84f739b26671faf2b2a15a91e5edb132bf1a Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Fri, 9 Feb 2024 14:18:59 -0500 Subject: [PATCH] Fix: python lttngust agent fails when LTTNG_UST_APP_PATH is not set Observed issue ============== lttng-tools `tests/regression/ust/python-logging/test_python_logging` had the following failures: ``` not ok 14 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 27 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 40 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 53 - Found 0 / 5 events matching 'python-ev-test1' out of 0 events not ok 66 - Found 0 / 1 events matching 'python-ev-test2' amongst 0 events not ok 74 - Found 0 / 1 events matching 'python-ev-test2' amongst 0 events not ok 82 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 98 - Found 0 / 1 events matching 'python-ev-test2' amongst 0 events not ok 109 - Found 0 / 5 events matching 'python-ev-test1' out of 0 events not ok 115 - Found 0 events matching 'python-ev-test1' not ok 121 - Found 0 / 1 events matching 'python-ev-test2' amongst 0 events not ok 127 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 134 - Found 0 / 10 events matching 'python-ev-test1' amongst 0 events not ok 140 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 146 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events not ok 157 - Found 0 / 5 events matching 'python-ev-test1' amongst 0 events ``` Cause ===== When the use of `LTTNG_UST_APP_PATH` was introduced[1], no default value for `ust_app_port` was set. In the case where `LTTNG_UST_APP_PATH` is not set in the environment the condition for starting with the `ust_app_port` is still checked, causing the following exception: ``` [2559145.907503] LTTng-UST warning: _init_threads(): cannot create client threads: cannot access local variable 'ust_app_port' where it is not associated with a value ``` Solution ======== Provide a known default value for `ust_app_port`. Known drawbacks =============== None. References ========== [1]: https://github.com/lttng/lttng-ust/commit/c0f6fb054d2f16518d047a6adf7e8aa81eff5403 Change-Id: I92242ccd056dd91505156e4e8df812639eaef570 Signed-off-by: Kienan Stewart Signed-off-by: Mathieu Desnoyers --- src/python-lttngust/lttngust/agent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python-lttngust/lttngust/agent.py b/src/python-lttngust/lttngust/agent.py index 58845b56..d0c1af7c 100644 --- a/src/python-lttngust/lttngust/agent.py +++ b/src/python-lttngust/lttngust/agent.py @@ -316,6 +316,7 @@ def _init_threads(): user_port = None dbg._pdebug('ust_app session daemon port: {}'.format(ust_app_port)) else: + ust_app_port = None sys_port = _get_port_from_file('/var/run/lttng/agent.port') user_port_file = os.path.join(_get_user_home_path(), '.lttng', 'agent.port') user_port = _get_port_from_file(user_port_file) -- 2.34.1