Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/fluent/fluent-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
gautampunhani committed Aug 4, 2021
2 parents 0ae4b53 + a2e1c47 commit 8f5902f
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,16 @@ endif()
# ============================

set(CPACK_PACKAGE_VERSION ${FLB_VERSION_STR})
set(CPACK_PACKAGE_NAME "td-agent-bit")

if(FLB_TD)
set(CPACK_PACKAGE_NAME "td-agent-bit")
else()
set(CPACK_PACKAGE_NAME "fluent-bit")
endif()

set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "Eduardo Silva <eduardo@treasure-data.com>")
set(CPACK_PACKAGE_VENDOR "Treasure Data")
set(CPACK_PACKAGE_CONTACT "Eduardo Silva <eduardo@calyptia.com>")
set(CPACK_PACKAGE_VENDOR "Calyptia Inc.")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGING_INSTALL_PREFIX "/")

Expand Down Expand Up @@ -925,7 +931,11 @@ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
# CPack: Windows System
if(CPACK_GENERATOR MATCHES "NSIS")
set(CPACK_MONOLITHIC_INSTALL 1)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "td-agent-bit")
if(FLB_TD)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "td-agent-bit")
else()
set(CPACK_PACKAGE_INSTALL_DIRECTORY "fluent-bit")
endif()
endif()

include(CPack)
2 changes: 1 addition & 1 deletion plugins/out_s3/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static int init_seq_index(void *context) {
}

/* Create directory path if it doesn't exist */
ret = mkdir(ctx->metadata_dir, 0600);
ret = mkdir(ctx->metadata_dir, 0700);
if (ret < 0 && errno != EEXIST) {
flb_plg_error(ctx->ins, "Failed to create metadata directory");
return -1;
Expand Down
6 changes: 6 additions & 0 deletions plugins/out_s3/s3_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ int complete_multipart_upload(struct flb_s3 *ctx,
struct flb_http_client *c = NULL;
struct flb_aws_client *s3_client;

if (!m_upload->upload_id) {
flb_plg_error(ctx->ins, "Cannot complete multipart upload for key %s: "
"upload ID is unset ", m_upload->s3_key);
return -1;
}

uri = flb_sds_create_size(flb_sds_len(m_upload->s3_key) + 11 +
flb_sds_len(m_upload->upload_id));
if (!uri) {
Expand Down
3 changes: 2 additions & 1 deletion src/flb_pack_gelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,8 @@ flb_sds_t flb_msgpack_to_gelf(flb_sds_t *s, msgpack_object *o,
}
*s = tmp;

tmp = flb_sds_printf(s, "%" PRIu32".%lu",
/* gelf supports milliseconds */
tmp = flb_sds_printf(s, "%" PRIu32".%03lu",
tm->tm.tv_sec, tm->tm.tv_nsec / 1000000);
if (tmp == NULL) {
return NULL;
Expand Down
47 changes: 46 additions & 1 deletion tests/internal/gelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,52 @@ void test_gelf_pack()
msgpack_sbuffer_destroy(&mp_sbuf);
}

#define EXPECTED_OUT_MSEC \
"{\"version\":\"1.1\", \"short_message\":\"true, 2019, str\", \"_t2\":\"false\", \"timestamp\":337647600.012}"

/* https://github.com/fluent/fluent-bit/issues/3727 */
void test_gelf_pack_msec()
{
msgpack_sbuffer mp_sbuf;
msgpack_packer mp_pck;
struct flb_time ts;
struct flb_gelf_fields fields = {0};
flb_sds_t out;

/* Pack sample msgpack */
msgpack_sbuffer_init(&mp_sbuf);
msgpack_packer_init(&mp_pck, &mp_sbuf, msgpack_sbuffer_write);


ts.tm.tv_sec = 337647600;
ts.tm.tv_nsec = 12341111; /* 12.34msec */

msgpack_pack_map(&mp_pck, 2);
msgpack_pack_str(&mp_pck, 2);
msgpack_pack_str_body(&mp_pck, "t1", 2);
msgpack_pack_array(&mp_pck, 3);
msgpack_pack_true(&mp_pck);
msgpack_pack_uint64(&mp_pck, 2019);
msgpack_pack_str(&mp_pck, 3);
msgpack_pack_str_body(&mp_pck, "str", 3);
msgpack_pack_str(&mp_pck, 2);
msgpack_pack_str_body(&mp_pck, "t2", 2);
msgpack_pack_false(&mp_pck);

fields.short_message_key = flb_sds_create("t1");
out = flb_msgpack_raw_to_gelf(mp_sbuf.data, mp_sbuf.size, &ts, &fields);
TEST_CHECK(out != NULL);

if(!TEST_CHECK(strcmp(out, EXPECTED_OUT_MSEC) == 0)) {
TEST_MSG("out=%s", out);
}
flb_sds_destroy(out);
flb_sds_destroy(fields.short_message_key);
msgpack_sbuffer_destroy(&mp_sbuf);
}

TEST_LIST = {
{"gelf_pack", test_gelf_pack},
{"gelf_pack", test_gelf_pack},
{"gelf_pack_msec", test_gelf_pack_msec},
{ 0 }
};

0 comments on commit 8f5902f

Please sign in to comment.