Skip to content

Commit dc7a6c8

Browse files
out_azure_blob: fixed review comments
Signed-off-by: Tanmaya Panda <[email protected]>
1 parent c9465ad commit dc7a6c8

File tree

3 files changed

+59
-55
lines changed

3 files changed

+59
-55
lines changed

plugins/out_azure_blob/azure_blob.c

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ static int create_blob(struct flb_azure_blob *ctx, char *name)
184184
ctx->u->base.flags &= ~(FLB_IO_ASYNC);
185185
ctx->u->base.net.io_timeout = ctx->io_timeout;
186186
}
187-
flb_plg_debug(ctx->ins, "create_blob -- async flag is %d", flb_stream_is_async(&ctx->u->base));
188187

189188
/* Get upstream connection */
190189
u_conn = flb_upstream_conn_get(ctx->u);
@@ -346,7 +345,6 @@ static int http_send_blob(struct flb_config *config, struct flb_azure_blob *ctx,
346345
ctx->u->base.flags &= ~(FLB_IO_ASYNC);
347346
ctx->u->base.net.io_timeout = ctx->io_timeout;
348347
}
349-
flb_plg_debug(ctx->ins, "send_blob -- async flag is %d", flb_stream_is_async(&ctx->u->base));
350348

351349
/* Get upstream connection */
352350
u_conn = flb_upstream_conn_get(ctx->u);
@@ -558,7 +556,6 @@ static int create_container(struct flb_azure_blob *ctx, char *name)
558556
ctx->u->base.flags &= ~(FLB_IO_ASYNC);
559557
ctx->u->base.net.io_timeout = ctx->io_timeout;
560558
}
561-
flb_plg_debug(ctx->ins, "create_container -- async flag is %d", flb_stream_is_async(&ctx->u->base));
562559

563560
/* Get upstream connection */
564561
u_conn = flb_upstream_conn_get(ctx->u);
@@ -657,7 +654,6 @@ static int ensure_container(struct flb_azure_blob *ctx)
657654
ctx->u->base.flags &= ~(FLB_IO_ASYNC);
658655
ctx->u->base.net.io_timeout = ctx->io_timeout;
659656
}
660-
flb_plg_debug(ctx->ins, "ensure_container -- async flag is %d", flb_stream_is_async(&ctx->u->base));
661657

662658
/* Get upstream connection */
663659
u_conn = flb_upstream_conn_get(ctx->u);
@@ -1299,7 +1295,8 @@ static void cb_azure_blob_ingest(struct flb_config *config, void *data) {
12991295
ret = azure_blob_store_file_delete(ctx, file);
13001296
if (ret == 0) {
13011297
flb_plg_debug(ctx->ins, "cb_azure_blob_ingest :: deleted successfully ingested file %s", fsf->name);
1302-
} else {
1298+
}
1299+
else {
13031300
flb_plg_error(ctx->ins, "cb_azure_blob_ingest :: failed to delete ingested file %s", fsf->name);
13041301
if (file) {
13051302
azure_blob_store_file_unlock(file);
@@ -1320,7 +1317,8 @@ static void cb_azure_blob_ingest(struct flb_config *config, void *data) {
13201317
file->fsf->name);
13211318
if (ctx->delete_on_max_upload_error){
13221319
azure_blob_store_file_delete(ctx, file);
1323-
}else{
1320+
}
1321+
else {
13241322
azure_blob_store_file_inactive(ctx, file);
13251323
}
13261324
}
@@ -1367,7 +1365,8 @@ static int ingest_all_chunks(struct flb_azure_blob *ctx, struct flb_config *conf
13671365
(char *) fsf->meta_buf, ctx->scheduler_max_retries);
13681366
if (ctx->delete_on_max_upload_error){
13691367
azure_blob_store_file_delete(ctx, chunk);
1370-
} else{
1368+
}
1369+
else {
13711370
azure_blob_store_file_inactive(ctx, chunk);
13721371
}
13731372
continue;
@@ -1439,7 +1438,8 @@ static void flush_init(void *out_context, struct flb_config *config)
14391438
ctx->fs->root_path);
14401439
FLB_OUTPUT_RETURN(FLB_RETRY);
14411440
}
1442-
}else{
1441+
}
1442+
else {
14431443
flb_plg_debug(ctx->ins,
14441444
"Did not find any local buffered data from previous "
14451445
"executions to azure blob; buffer=%s",
@@ -1496,7 +1496,8 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
14961496

14971497
if (ctx->unify_tag == FLB_TRUE) {
14981498
tag_name = flb_sds_create("fluentbit-buffer-file-unify-tag.log");
1499-
} else {
1499+
}
1500+
else {
15001501
tag_name = event_chunk->tag;
15011502
}
15021503
tag_len = flb_sds_len(tag_name);
@@ -1567,21 +1568,24 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
15671568
flb_plg_debug(ctx->ins, "uploaded file %s successfully", upload_file->fsf->name);
15681569
azure_blob_store_file_delete(ctx, upload_file);
15691570
goto cleanup;
1570-
} else {
1571+
}
1572+
else {
15711573
flb_plg_error(ctx->ins, "error uploading file %s", upload_file->fsf->name);
15721574
if (upload_file) {
15731575
azure_blob_store_file_unlock(upload_file);
15741576
upload_file->failures += 1;
15751577
}
15761578
goto error;
15771579
}
1578-
} else {
1580+
}
1581+
else {
15791582
/* Buffer current chunk */
15801583
ret = azure_blob_store_buffer_put(ctx, upload_file, tag_name, tag_len, json, json_size);
15811584
if (ret == 0) {
15821585
flb_plg_debug(ctx->ins, "buffered chunk %s", event_chunk->tag);
15831586
goto cleanup;
1584-
} else {
1587+
}
1588+
else {
15851589
flb_plg_error(ctx->ins, "failed to buffer chunk %s", event_chunk->tag);
15861590
goto error;
15871591
}
@@ -1610,7 +1614,8 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk,
16101614
flb_free(final_payload);
16111615
}
16121616
FLB_OUTPUT_RETURN(FLB_RETRY);
1613-
} else {
1617+
}
1618+
else {
16141619

16151620
/*
16161621
* Azure blob requires a container. The following function validate that the container exists,
@@ -1890,75 +1895,76 @@ static struct flb_config_map config_map[] = {
18901895
},
18911896

18921897
{
1893-
FLB_CONFIG_MAP_BOOL, "buffering_enabled", "false",
1894-
0, FLB_TRUE, offsetof(struct flb_azure_blob, buffering_enabled),
1895-
"Enable buffering into disk before ingesting into Azure Blob."
1898+
FLB_CONFIG_MAP_BOOL, "buffering_enabled", "false",
1899+
0, FLB_TRUE, offsetof(struct flb_azure_blob, buffering_enabled),
1900+
"Enable buffering into disk before ingesting into Azure Blob"
18961901
},
18971902

18981903
{
1899-
FLB_CONFIG_MAP_STR, "buffer_dir", "/tmp/fluent-bit/azure-blob/",
1900-
0, FLB_TRUE, offsetof(struct flb_azure_blob, buffer_dir),
1901-
"Specifies the location of directory where the buffered data will be stored."
1904+
FLB_CONFIG_MAP_STR, "buffer_dir", "/tmp/fluent-bit/azure-blob/",
1905+
0, FLB_TRUE, offsetof(struct flb_azure_blob, buffer_dir),
1906+
"Specifies the location of directory where the buffered data will be stored"
19021907
},
19031908

19041909
{
1905-
FLB_CONFIG_MAP_TIME, "upload_timeout", "30m",
1906-
0, FLB_TRUE, offsetof(struct flb_azure_blob, upload_timeout),
1907-
"Optionally specify a timeout for uploads. "
1908-
"Fluent Bit will start ingesting buffer files which have been created more than x minutes and haven't reached upload_file_size limit yet. "
1909-
" Default is 30m."
1910+
FLB_CONFIG_MAP_TIME, "upload_timeout", "30m",
1911+
0, FLB_TRUE, offsetof(struct flb_azure_blob, upload_timeout),
1912+
"Optionally specify a timeout for uploads. "
1913+
"Fluent Bit will start ingesting buffer files which have been created more than x minutes and haven't reached upload_file_size limit yet"
1914+
"Default is 30m."
19101915
},
19111916

19121917
{
1913-
FLB_CONFIG_MAP_SIZE, "upload_file_size", "200M",
1914-
0, FLB_TRUE, offsetof(struct flb_azure_blob, file_size),
1915-
"Specifies the size of files to be uploaded in MBs. Default is 200MB"
1918+
FLB_CONFIG_MAP_SIZE, "upload_file_size", "200M",
1919+
0, FLB_TRUE, offsetof(struct flb_azure_blob, file_size),
1920+
"Specifies the size of files to be uploaded in MBs. Default is 200MB"
19161921
},
19171922

19181923
{
1919-
FLB_CONFIG_MAP_STR, "azure_blob_buffer_key", "key",
1920-
0, FLB_TRUE, offsetof(struct flb_azure_blob, azure_blob_buffer_key),
1921-
"Set the azure blob buffer key which needs to be specified when using multiple instances of azure blob output plugin and buffering is enabled"
1924+
FLB_CONFIG_MAP_STR, "azure_blob_buffer_key", "key",
1925+
0, FLB_TRUE, offsetof(struct flb_azure_blob, azure_blob_buffer_key),
1926+
"Set the azure blob buffer key which needs to be specified when using multiple instances of azure blob output plugin and buffering is enabled"
19221927
},
19231928

19241929
{
1925-
FLB_CONFIG_MAP_SIZE, "store_dir_limit_size", "8G",
1926-
0, FLB_TRUE, offsetof(struct flb_azure_blob, store_dir_limit_size),
1927-
"Set the max size of the buffer directory. Default is 8GB"
1930+
FLB_CONFIG_MAP_SIZE, "store_dir_limit_size", "8G",
1931+
0, FLB_TRUE, offsetof(struct flb_azure_blob, store_dir_limit_size),
1932+
"Set the max size of the buffer directory. Default is 8GB"
19281933
},
19291934

19301935
{
1931-
FLB_CONFIG_MAP_BOOL, "buffer_file_delete_early", "false",
1932-
0, FLB_TRUE, offsetof(struct flb_azure_blob, buffer_file_delete_early),
1933-
"Whether to delete the buffered file early after successful blob creation. Default is false"
1936+
FLB_CONFIG_MAP_BOOL, "buffer_file_delete_early", "false",
1937+
0, FLB_TRUE, offsetof(struct flb_azure_blob, buffer_file_delete_early),
1938+
"Whether to delete the buffered file early after successful blob creation. Default is false"
19341939
},
19351940

1936-
{ FLB_CONFIG_MAP_INT, "blob_uri_length", "64",
1937-
0, FLB_TRUE, offsetof(struct flb_azure_blob, blob_uri_length),
1938-
"Set the length of generated blob uri before ingesting to Azure Kusto. Default is 64"
1941+
{
1942+
FLB_CONFIG_MAP_INT, "blob_uri_length", "64",
1943+
0, FLB_TRUE, offsetof(struct flb_azure_blob, blob_uri_length),
1944+
"Set the length of generated blob uri before ingesting to Azure Kusto. Default is 64"
19391945
},
19401946

19411947
{
1942-
FLB_CONFIG_MAP_BOOL, "unify_tag", "false",
1943-
0, FLB_TRUE, offsetof(struct flb_azure_blob, unify_tag),
1944-
"Whether to create a single buffer file when buffering mode is enabled. Default is false"
1948+
FLB_CONFIG_MAP_BOOL, "unify_tag", "false",
1949+
0, FLB_TRUE, offsetof(struct flb_azure_blob, unify_tag),
1950+
"Whether to create a single buffer file when buffering mode is enabled. Default is false"
19451951
},
19461952

19471953
{
1948-
FLB_CONFIG_MAP_INT, "scheduler_max_retries", "3",
1949-
0, FLB_TRUE, offsetof(struct flb_azure_blob, scheduler_max_retries),
1950-
"Maximum number of retries for the scheduler send blob. Default is 3"
1954+
FLB_CONFIG_MAP_INT, "scheduler_max_retries", "3",
1955+
0, FLB_TRUE, offsetof(struct flb_azure_blob, scheduler_max_retries),
1956+
"Maximum number of retries for the scheduler send blob. Default is 3"
19511957
},
19521958

19531959
{
1954-
FLB_CONFIG_MAP_BOOL, "delete_on_max_upload_error", "false",
1955-
0, FLB_TRUE, offsetof(struct flb_azure_blob, delete_on_max_upload_error),
1956-
"Whether to delete the buffer file on maximum upload errors. Default is false"
1960+
FLB_CONFIG_MAP_BOOL, "delete_on_max_upload_error", "false",
1961+
0, FLB_TRUE, offsetof(struct flb_azure_blob, delete_on_max_upload_error),
1962+
"Whether to delete the buffer file on maximum upload errors. Default is false"
19571963
},
19581964

19591965
{
1960-
FLB_CONFIG_MAP_TIME, "io_timeout", "60s",0, FLB_TRUE, offsetof(struct flb_azure_blob, io_timeout),
1961-
"HTTP IO timeout. Default is 60s"
1966+
FLB_CONFIG_MAP_TIME, "io_timeout", "60s",0, FLB_TRUE, offsetof(struct flb_azure_blob, io_timeout),
1967+
"HTTP IO timeout. Default is 60s"
19621968
},
19631969

19641970
/* EOF */

plugins/out_azure_blob/azure_blob_blockblob.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ int azb_block_blob_put_block_list(struct flb_azure_blob *ctx, flb_sds_t uri, flb
262262
ctx->u->base.flags &= ~(FLB_IO_ASYNC);
263263
ctx->u->base.net.io_timeout = ctx->io_timeout;
264264
}
265-
flb_plg_debug(ctx->ins, "azb_block_blob_put_block_list -- async flag is %d", flb_stream_is_async(&ctx->u->base));
266265

267266
/* Get upstream connection */
268267
u_conn = flb_upstream_conn_get(ctx->u);

plugins/out_azure_blob/azure_blob_store.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ static flb_sds_t gen_store_filename(const char *tag)
4747
/* flb_sds_printf allocs if the incoming sds is not at least 64 bytes */
4848
hash_str = flb_sds_create_size(64);
4949
if (!hash_str) {
50-
flb_errno();
5150
return NULL;
5251
}
5352
tmp = flb_sds_printf(&hash_str, "%lu-%lu", hash, hash2);
5453
if (!tmp) {
55-
flb_errno();
5654
flb_sds_destroy(hash_str);
5755
return NULL;
5856
}
@@ -93,7 +91,7 @@ struct azure_blob_file *azure_blob_store_file_get(struct flb_azure_blob *ctx, co
9391
/* skip locked chunks */
9492
azure_blob_file = fsf->data;
9593
if (azure_blob_file->locked == FLB_TRUE) {
96-
flb_plg_debug(ctx->ins, "File '%s' is locked, skipping", fsf->name);
94+
flb_plg_debug(ctx->ins, "File '%s' is being processed by another worker, continuing search", fsf->name);
9795
fsf = NULL;
9896
continue;
9997
}
@@ -174,7 +172,8 @@ int azure_blob_store_buffer_put(struct flb_azure_blob *ctx, struct azure_blob_fi
174172
fsf->data = azure_blob_file;
175173
flb_sds_destroy(name);
176174

177-
}else {
175+
}
176+
else {
178177
fsf = azure_blob_file->fsf;
179178
}
180179

0 commit comments

Comments
 (0)