src.ctf.fs: improve `metadata-info` query error message with non-existent metadata...
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 19 Oct 2023 17:25:40 +0000 (13:25 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 20 Oct 2023 23:26:25 +0000 (19:26 -0400)
commit0ac40cd4cd6b16ecd99fbab2f51269cfdf59e78e
tree1a14b8c76cab14e7c1622a30a47472368b6b4c1f
parentccc24971f78f33d9a9cb63ae277882ae43c35b3f
src.ctf.fs: improve `metadata-info` query error message with non-existent metadata file

A colleague pointed out that the message babeltrace2 outputs when
pointing the `metadata-info` query to a directory without a metadata
file (or a non-existent directory) is not clear as it could be.

    ERROR:    [Babeltrace CLI] (/home/smarchi/src/babeltrace/src/cli/babeltrace2.c:651)
      Failed to query component class: unknown error: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=SOURCE object="metadata-info"
    CAUSED BY [libbabeltrace2] (/home/smarchi/src/babeltrace/src/lib/graph/query-executor.c:234)
      Component class's "query" method failed: query-exec-addr=0x60b000000880, cc-addr=0x60f000000130, cc-type=SOURCE, cc-name="fs", cc-partial-descr="Read CTF traces from the file sy",
      cc-is-frozen=0, cc-so-handle-addr=0x607000000020, cc-so-handle-path="/home/smarchi/build/babeltrace/src/plugins/ctf/babeltrace-plugin-ctf.la", object="metadata-info",
      params-addr=0x606000000500, params-type=MAP, params-element-count=1, log-level=WARNING
    CAUSED BY ['source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/fs-src/query.cpp:92)
      Cannot open trace metadata: path="yoyoyo".

In the ctf_fs_metadata_open_file function, we could have access to the
errno that explains the failure, but currently don't use it.  Also, it
would be good to tell which file we tried to open exactly.  Make
ctf_fs_metadata_open_file log an error and append an error cause.

The new error stack is the same as the above, with this new cause at the
end:

    CAUSED BY ['source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/fs-src/metadata.cpp:41)
      Failed to open metadata file: No such file or directory: path="yoyoyo/metadata"

Add a test that validates that this error cause is present in the error
message.

Change-Id: I111848cc72e6f3b2cdfb251914eb337ea02a19f4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11079
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
src/plugins/ctf/fs-src/metadata.cpp
src/plugins/ctf/fs-src/metadata.hpp
src/plugins/ctf/fs-src/query.cpp
tests/plugins/src.ctf.fs/query/test_query_metadata_info
This page took 0.028339 seconds and 4 git commands to generate.