Generate session name and default output on sessiond's end
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 8 Apr 2019 19:44:01 +0000 (15:44 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 24 Apr 2019 23:30:47 +0000 (19:30 -0400)
commit5feee5031b7ff06f27bc5574cf4871c1b7282ab3
treef95372f8923c17fd967c6d4e2dc6c1f8f9ad308a
parent263fa20d53f11a189ca5a947f55240efcb12262c
Generate session name and default output on sessiond's end

The lttng client currently generates the default session name and
output parameters. This has, over time, resulted in a number of
problems. Notably, it is possible for scripts to create session
too quickly using automatically-generated session names that would
clash since the session's creation timestamp is the only variable part
of a session "automatic" name. Hence, sessions created in the same
second would clash and result in spurious session creation failures.

More importantly, generating session names and outputs on the client
end makes it impossible to reliably differentiate output locations that
were automatically generated vs. those that were explicitly provided.

This causes destinations to be "opaque" to the LTTng daemons as
the subdir, session name, and session's creation timestamp are all
"cooked" as part of the output destination path/subdir. Keeping these
path components separate will make it easier to implement output path
configurations that allow the grouping of session outputs by name, by
host, etc.

Since a session's creation time is used as part of its shm-path, an
accessor to the session's creation time is added to the public API:
lttng_session_get_creation_time(). This creation time attribute can be
accessed when an lttng_session structure is created using the session
listing API.

Note that existing session creation functions are preserved to
maintain the binary compatibility with existing liblttng-ctl users.
The session creation functions are reimplemented on top of this
newly-introduced API. The only function for which compatibility is
dropped is the hidden _lttng_create_session_ext().

Overhaul of path separation
---

Not generating paths on the client-end has uncovered a number
of problems in the path handling of the session daemon, especially
when a network output was used. A lot of code presumed that a
network session would be created with a URL containing a sub-directory
of the form "session_name-timestamp". While this is true for
remote sessions created by the lttng client, a sub-directory is
not required when liblttng-ctl is used directly.

Hence, this commit ensures that session directories are split
as base path, chunk directory, domain directory, application
directory.

A number of changes in this fix ensure that a session's base path
contains everything up to the "session" path element _or_ up to
the user-specified output directory.

For example, creating a local session using default output settings,
the session base output is:
  /home/user/lttng-traces/session-timestamp

Creating a remote session using default output settings, the session
base output path is:
  /hostname/session-timestamp/

Using custom output directories, whether locally or remotely, causes
the session base path to be set to that custom output directory.
For example, using a local output path of /tmp/my_path will result
in a session base path of the form:
  /tmp/my_path

Whereas creating a session with a network output of
net://localhost/my_path will result in a session base path of the
form:
  /hostname/my_path

Another problematic element is the subdir of the kernel_session
and ust_session consumer output which in different scenarios
contained chunk names and arbitrary parts of the path hierarchy.

The consumer output subdir has been renamed to 'domain_subdir'
and now only ever contains: "kernel/", "ust/", or "".

Finally, the chunk_path session attribute only contains the name
of the current chunk directory being produced.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
32 files changed:
extras/bindings/swig/python/lttng.i.in
include/Makefile.am
include/lttng/lttng-error.h
include/lttng/lttng.h
include/lttng/session-descriptor-internal.h [new file with mode: 0644]
include/lttng/session-descriptor.h [new file with mode: 0644]
include/lttng/session-internal.h [new file with mode: 0644]
include/lttng/session.h
src/bin/lttng-sessiond/client.c
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/cmd.h
src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/kernel-consumer.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/rotate.c
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/session.h
src/bin/lttng-sessiond/snapshot.c
src/bin/lttng-sessiond/snapshot.h
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-consumer.c
src/bin/lttng-sessiond/utils.c
src/bin/lttng/commands/create.c
src/common/Makefile.am
src/common/error.c
src/common/session-descriptor.c [new file with mode: 0644]
src/common/sessiond-comm/sessiond-comm.h
src/lib/lttng-ctl/lttng-ctl.c
tests/regression/tools/snapshots/test_kernel_streaming
tests/regression/tools/snapshots/test_ust_streaming
tests/unit/test_session.c
This page took 0.030903 seconds and 4 git commands to generate.