Fix backward compatibility of session daemon 2.11 with relayd versions
prior to 2.11.
Session daemon and consumer daemon 2.11 use the "chunk" object to
represent the current output directory. However, both sessiond and
consumerd need to ensure they do not send chunk and rotation commands
to a relayd older than 2.11, and tweak the stream paths accordingly.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- if (session->output_traces && !session->current_trace_chunk &&
- session_output_supports_trace_chunks(session)) {
+ if (session->output_traces && !session->current_trace_chunk) {
struct lttng_trace_chunk *trace_chunk;
trace_chunk = session_create_new_trace_chunk(
struct lttng_trace_chunk *trace_chunk;
trace_chunk = session_create_new_trace_chunk(
if (reply_context) {
reply_context->implicit_rotation_on_destroy = true;
}
if (reply_context) {
reply_context->implicit_rotation_on_destroy = true;
}
- } else if (session->has_been_started && session->current_trace_chunk &&
- session_output_supports_trace_chunks(session)) {
+ } else if (session->has_been_started && session->current_trace_chunk) {
/*
* The user has not triggered a session rotation. However, to
* ensure all data has been consumed, the session is rotated
/*
* The user has not triggered a session rotation. However, to
* ensure all data has been consumed, the session is rotated
}
/* Unsupported feature in lttng-relayd before 2.11. */
}
/* Unsupported feature in lttng-relayd before 2.11. */
- if (session->consumer->type == CONSUMER_DST_NET &&
+ if (!quiet_rotation && session->consumer->type == CONSUMER_DST_NET &&
(session->consumer->relay_major_version == 2 &&
session->consumer->relay_minor_version < 11)) {
cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_RELAY;
(session->consumer->relay_major_version == 2 &&
session->consumer->relay_minor_version < 11)) {
cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_RELAY;
-bool session_output_supports_trace_chunks(const struct ltt_session *session)
-{
- const struct consumer_output *output = session->kernel_session ?
- session->kernel_session->consumer :
- session->ust_session->consumer;
-
- if (output->type == CONSUMER_DST_LOCAL) {
- return true;
- } else {
- if (output->relay_major_version > 2) {
- return true;
- } else if (output->relay_major_version == 2 &&
- output->relay_minor_version >= 11) {
- return true;
- }
- }
- return false;
-}
-
struct lttng_trace_chunk *session_create_new_trace_chunk(
const struct ltt_session *session,
const struct consumer_output *consumer_output_override,
struct lttng_trace_chunk *session_create_new_trace_chunk(
const struct ltt_session *session,
const struct consumer_output *consumer_output_override,
+static
+bool relayd_supports_chunks(const struct lttcomm_relayd_sock *sock)
+{
+ if (sock->major > 2) {
+ return true;
+ } else if (sock->major == 2 && sock->minor >= 11) {
+ return true;
+ }
+ return false;
+}
+
/*
* Send command. Fill up the header and append the data.
*/
/*
* Send command. Fill up the header and append the data.
*/
/*
* Add stream on the relayd and assign stream handle to the stream_id argument.
*
/*
* Add stream on the relayd and assign stream handle to the stream_id argument.
*
+ * Chunks are not supported by relayd prior to 2.11, but are used to
+ * internally between session daemon and consumer daemon to keep track
+ * of the channel and stream output path.
+ *
* On success return 0 else return ret_code negative value.
*/
int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_name,
* On success return 0 else return ret_code negative value.
*/
int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_name,
assert(rsock);
assert(channel_name);
assert(pathname);
assert(rsock);
assert(channel_name);
assert(pathname);
DBG("Relayd adding stream for channel name %s", channel_name);
/* Compat with relayd 2.1 */
if (rsock->minor == 1) {
/* For 2.1 */
DBG("Relayd adding stream for channel name %s", channel_name);
/* Compat with relayd 2.1 */
if (rsock->minor == 1) {
/* For 2.1 */
ret = relayd_add_stream_2_1(rsock, channel_name, pathname);
} else if (rsock->minor > 1 && rsock->minor < 11) {
/* From 2.2 to 2.10 */
ret = relayd_add_stream_2_1(rsock, channel_name, pathname);
} else if (rsock->minor > 1 && rsock->minor < 11) {
/* From 2.2 to 2.10 */
ret = relayd_add_stream_2_2(rsock, channel_name, pathname,
tracefile_size, tracefile_count);
} else {
enum lttng_trace_chunk_status chunk_status;
uint64_t chunk_id;
ret = relayd_add_stream_2_2(rsock, channel_name, pathname,
tracefile_size, tracefile_count);
} else {
enum lttng_trace_chunk_status chunk_status;
uint64_t chunk_id;
chunk_status = lttng_trace_chunk_get_id(trace_chunk,
&chunk_id);
assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
chunk_status = lttng_trace_chunk_get_id(trace_chunk,
&chunk_id);
assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
char new_chunk_id_buf[MAX_INT_DEC_LEN(*new_chunk_id)] = {};
const char *new_chunk_id_str;
char new_chunk_id_buf[MAX_INT_DEC_LEN(*new_chunk_id)] = {};
const char *new_chunk_id_str;
+ if (!relayd_supports_chunks(sock)) {
+ DBG("Refusing to rotate remote streams: relayd does not support chunks");
+ return 0;
+ }
+
lttng_dynamic_buffer_init(&payload);
/* Code flow error. Safety net. */
lttng_dynamic_buffer_init(&payload);
/* Code flow error. Safety net. */
lttng_dynamic_buffer_init(&payload);
lttng_dynamic_buffer_init(&payload);
+ if (!relayd_supports_chunks(sock)) {
+ DBG("Refusing to create remote trace chunk: relayd does not support chunks");
+ goto end;
+ }
+
status = lttng_trace_chunk_get_id(chunk, &chunk_id);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
status = lttng_trace_chunk_get_id(chunk, &chunk_id);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
time_t close_timestamp;
LTTNG_OPTIONAL(enum lttng_trace_chunk_command_type) close_command = {};
time_t close_timestamp;
LTTNG_OPTIONAL(enum lttng_trace_chunk_command_type) close_command = {};
+ if (!relayd_supports_chunks(sock)) {
+ DBG("Refusing to close remote trace chunk: relayd does not support chunks");
+ goto end;
+ }
+
status = lttng_trace_chunk_get_id(chunk, &chunk_id);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to get trace chunk id");
status = lttng_trace_chunk_get_id(chunk, &chunk_id);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to get trace chunk id");
struct lttcomm_relayd_trace_chunk_exists msg = {};
struct lttcomm_relayd_trace_chunk_exists_reply reply = {};
struct lttcomm_relayd_trace_chunk_exists msg = {};
struct lttcomm_relayd_trace_chunk_exists_reply reply = {};
+ if (!relayd_supports_chunks(sock)) {
+ DBG("Refusing to check for trace chunk existence: relayd does not support chunks");
+ goto end;
+ }
+
msg = (typeof(msg)){
.chunk_id = htobe64(chunk_id),
};
msg = (typeof(msg)){
.chunk_id = htobe64(chunk_id),
};