Skip to content

Commit

Permalink
multiline: cri don't create msgpack buffer until validating time
Browse files Browse the repository at this point in the history
Signed-off-by: ryanohnemus <[email protected]>
  • Loading branch information
ryanohnemus committed Jan 9, 2025
1 parent 9f0a5f6 commit 9bdd4e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/flb_parser_cri.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ int flb_parser_cri_do(struct flb_parser *parser,
return -1;
}

/* Prepare new outgoing buffer, then add time to it */
msgpack_sbuffer_init(&tmp_sbuf);
msgpack_packer_init(&tmp_pck, &tmp_sbuf, msgpack_sbuffer_write);
msgpack_pack_map(&tmp_pck, map_size);

struct flb_tm tm = {0};
ret = flb_parser_time_lookup(in_buf, token_end-in_buf-1,
ret = flb_parser_time_lookup(in_buf, token_end-in_buf,
0, parser, &tm, &tmfrac);
if (ret == -1) {
flb_error("[parser:%s] Invalid time format %s",
parser->name, parser->time_fmt_full);
return -1;
}

/* Prepare new outgoing buffer, then add time to it */
msgpack_sbuffer_init(&tmp_sbuf);
msgpack_packer_init(&tmp_pck, &tmp_sbuf, msgpack_sbuffer_write);
msgpack_pack_map(&tmp_pck, map_size);

msgpack_pack_str(&tmp_pck, time_key_len);
msgpack_pack_str_body(&tmp_pck, time_key, time_key_len);
msgpack_pack_str(&tmp_pck, token_end-in_buf);
Expand Down
7 changes: 2 additions & 5 deletions src/multiline/flb_ml_parser_cri.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include <fluent-bit/multiline/flb_ml.h>
#include <fluent-bit/multiline/flb_ml_parser.h>

//Reverting change for fuzz test...
#define FLB_ML_CRI_REGEX \
"^(?<time>.+?) (?<stream>stdout|stderr) (?<_p>F|P) (?<log>.*)$"
#define FLB_ML_CRI_TIME \
"%Y-%m-%dT%H:%M:%S.%L%z"

Expand All @@ -33,8 +30,8 @@ static struct flb_parser *cri_parser_create(struct flb_config *config)
struct flb_parser *p;

p = flb_parser_create("_ml_cri", /* parser name */
"regex", //"cri", /* backend type */
FLB_ML_CRI_REGEX, //NULL, /* regex */
"cri", /* backend type */
NULL, /* regex */
FLB_FALSE, /* skip_empty */
FLB_ML_CRI_TIME, /* time format */
"time", /* time key */
Expand Down

0 comments on commit 9bdd4e3

Please sign in to comment.