Skip to content

Commit 542a4a9

Browse files
committed
out_cloudwatch_logs: Set up expire time as 0 on eviction
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 9b1fcbd commit 542a4a9

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

plugins/out_cloudwatch_logs/cloudwatch_api.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,15 +1642,13 @@ struct log_stream *get_or_create_log_stream(struct flb_cloudwatch *ctx,
16421642
now = time(NULL);
16431643
mk_list_foreach_safe(head, tmp, &ctx->streams) {
16441644
stream = mk_list_entry(head, struct log_stream, _head);
1645-
if (strcmp(stream_name, stream->name) == 0 && strcmp(group_name, stream->group) == 0) {
1646-
return stream;
1645+
if (stream->expiration < now) {
1646+
mk_list_del(&stream->_head);
1647+
log_stream_destroy(stream);
16471648
}
1648-
else {
1649-
/* check if stream is expired, if so, clean it up */
1650-
if (stream->expiration < now) {
1651-
mk_list_del(&stream->_head);
1652-
log_stream_destroy(stream);
1653-
}
1649+
else if (strcmp(stream_name, stream->name) == 0 &&
1650+
strcmp(group_name, stream->group) == 0) {
1651+
return stream;
16541652
}
16551653
}
16561654

@@ -2116,6 +2114,7 @@ int put_log_events(struct flb_cloudwatch *ctx, struct cw_flush *buf,
21162114
flb_plg_error(ctx->ins, "Log stream %s not found. "
21172115
"Rejecting the chunk without retry.",
21182116
stream->name);
2117+
stream->expiration = 0;
21192118
buf->non_retriable_error = FLB_TRUE;
21202119
flb_sds_destroy(error);
21212120
flb_http_client_destroy(c);

0 commit comments

Comments
 (0)