Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out_cloudwatch_logs: fix logic in free-ing log streams on shutdown #7159

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions plugins/out_cloudwatch_logs/cloudwatch_logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,6 @@ static int cb_cloudwatch_init(struct flb_output_instance *ins,
ctx->sts_endpoint = (char *) tmp;
}

/* init log streams */
if (ctx->log_stream_name) {
ctx->stream.name = flb_sds_create(ctx->log_stream_name);
if (!ctx->stream.name) {
flb_errno();
goto error;
}
ctx->stream_created = FLB_FALSE;
}

/* one tls instance for provider, one for cw client */
ctx->cred_tls = flb_tls_create(FLB_TLS_CLIENT_MODE,
FLB_TRUE,
Expand Down Expand Up @@ -484,19 +474,10 @@ void flb_cloudwatch_ctx_destroy(struct flb_cloudwatch *ctx)
flb_sds_destroy(ctx->stream_name);
}

if (ctx->log_stream_name) {
if (ctx->stream.name) {
flb_sds_destroy(ctx->stream.name);
}
if (ctx->stream.sequence_token) {
flb_sds_destroy(ctx->stream.sequence_token);
}
} else {
mk_list_foreach_safe(head, tmp, &ctx->streams) {
stream = mk_list_entry(head, struct log_stream, _head);
mk_list_del(&stream->_head);
log_stream_destroy(stream);
}
mk_list_foreach_safe(head, tmp, &ctx->streams) {
stream = mk_list_entry(head, struct log_stream, _head);
mk_list_del(&stream->_head);
log_stream_destroy(stream);
}
flb_free(ctx);
}
Expand Down
5 changes: 1 addition & 4 deletions plugins/out_cloudwatch_logs/cloudwatch_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ struct flb_cloudwatch {
struct flb_record_accessor *ra_group;
struct flb_record_accessor *ra_stream;

/* if we're writing to a static log stream, we'll use this */
struct log_stream stream;
int stream_created;
/* if the log stream is dynamic, we'll use this */
/* stores log streams we're putting to */
struct mk_list streams;

/* buffers for data processing and request payload */
Expand Down