Skip to content

Commit aeb2747

Browse files
authored
Merge branch 'master' into fix-storage-inherit-test
Signed-off-by: Jorge Niedbalski <[email protected]>
2 parents 896734e + a28a631 commit aeb2747

31 files changed

+1970
-111
lines changed

include/fluent-bit/flb_api.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <fluent-bit/flb_info.h>
2424
#include <fluent-bit/flb_output.h>
25+
#include <fluent-bit/flb_custom.h>
2526

2627
struct flb_api {
2728
const char *(*output_get_property) (const char *, struct flb_output_instance *);
@@ -33,6 +34,11 @@ struct flb_api {
3334
void (*log_print) (int, const char*, int, const char*, ...);
3435
int (*input_log_check) (struct flb_input_instance *, int);
3536
int (*output_log_check) (struct flb_output_instance *, int);
37+
38+
/* To preserve ABI, we need to add these APIs after the
39+
* input/output definitions. */
40+
const char *(*custom_get_property) (const char *, struct flb_custom_instance *);
41+
int (*custom_log_check) (struct flb_custom_instance *, int);
3642
};
3743

3844
#ifdef FLB_CORE

include/fluent-bit/flb_config.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ struct flb_config {
6767
* shutdown when all remaining tasks are flushed
6868
*/
6969
int grace;
70-
int grace_count; /* Count of grace shutdown tries */
71-
flb_pipefd_t flush_fd; /* Timer FD associated to flush */
72-
int convert_nan_to_null; /* convert null to nan ? */
70+
int grace_count; /* Count of grace shutdown tries */
71+
int grace_input; /* Shutdown grace to keep inputs ingesting */
72+
flb_pipefd_t flush_fd; /* Timer FD associated to flush */
73+
int convert_nan_to_null; /* Convert null to nan ? */
7374

7475
int daemon; /* Run as a daemon ? */
7576
flb_pipefd_t shutdown_fd; /* Shutdown FD, 5 seconds */
@@ -243,6 +244,7 @@ struct flb_config {
243244
int storage_max_chunks_up; /* max number of chunks 'up' in memory */
244245
int storage_del_bad_chunks; /* delete irrecoverable chunks */
245246
char *storage_bl_mem_limit; /* storage backlog memory limit */
247+
int storage_bl_flush_on_shutdown; /* enable/disable backlog chunks flush on shutdown */
246248
struct flb_storage_metrics *storage_metrics_ctx; /* storage metrics context */
247249
int storage_trim_files; /* enable/disable file trimming */
248250
char *storage_type; /* global storage type */
@@ -394,6 +396,8 @@ enum conf_type {
394396
#define FLB_CONF_STORAGE_METRICS "storage.metrics"
395397
#define FLB_CONF_STORAGE_CHECKSUM "storage.checksum"
396398
#define FLB_CONF_STORAGE_BL_MEM_LIMIT "storage.backlog.mem_limit"
399+
#define FLB_CONF_STORAGE_BL_FLUSH_ON_SHUTDOWN \
400+
"storage.backlog.flush_on_shutdown"
397401
#define FLB_CONF_STORAGE_MAX_CHUNKS_UP "storage.max_chunks_up"
398402
#define FLB_CONF_STORAGE_DELETE_IRRECOVERABLE_CHUNKS \
399403
"storage.delete_irrecoverable_chunks"

include/fluent-bit/flb_custom.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,20 @@
3131
#define FLB_CUSTOM_NET_CLIENT 1 /* custom may use upstream net.* properties */
3232
#define FLB_CUSTOM_NET_SERVER 2 /* custom may use downstream net.* properties */
3333

34+
/* Custom plugin types */
35+
#define FLB_CUSTOM_PLUGIN_CORE 0
36+
#define FLB_CUSTOM_PLUGIN_PROXY 1
37+
3438
struct flb_custom_instance;
3539

3640
struct flb_custom_plugin {
41+
/*
42+
* The type defines if this is a core-based plugin or it's handled by
43+
* some specific proxy.
44+
*/
45+
int type;
46+
void *proxy;
47+
3748
int flags; /* Flags (not available at the moment */
3849
char *name; /* Custom plugin short name */
3950
char *description; /* Description */
@@ -49,6 +60,9 @@ struct flb_custom_plugin {
4960
void *, struct flb_config *);
5061
int (*cb_exit) (void *, struct flb_config *);
5162

63+
/* Destroy */
64+
void (*cb_destroy) (struct flb_custom_plugin *);
65+
5266
struct mk_list _head; /* Link to parent list (config->custom) */
5367
};
5468

@@ -96,5 +110,6 @@ int flb_custom_plugin_property_check(struct flb_custom_instance *ins,
96110
int flb_custom_init_all(struct flb_config *config);
97111
void flb_custom_set_context(struct flb_custom_instance *ins, void *context);
98112
void flb_custom_instance_destroy(struct flb_custom_instance *ins);
113+
int flb_custom_log_check(struct flb_custom_instance *ins, int l);
99114

100115
#endif

include/fluent-bit/flb_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ int flb_engine_exit_status(struct flb_config *config, int status);
3737
int flb_engine_shutdown(struct flb_config *config);
3838
int flb_engine_destroy_tasks(struct mk_list *tasks);
3939
void flb_engine_reschedule_retries(struct flb_config *config);
40+
void flb_engine_stop_ingestion(struct flb_config *config);
4041

4142
/* Engine event loop */
4243
void flb_engine_evl_init();

include/fluent-bit/flb_plugin_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
/* Plugin Types */
2929
#define FLB_PROXY_INPUT_PLUGIN 1
3030
#define FLB_PROXY_OUTPUT_PLUGIN 2
31+
#define FLB_PROXY_CUSTOM_PLUGIN 3
3132

3233
/* Proxies available */
3334
#define FLB_PROXY_GOLANG 11

include/fluent-bit/flb_plugins.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ void flb_plugins_unregister(struct flb_config *config)
6464

6565
mk_list_foreach_safe(head, tmp, &config->custom_plugins) {
6666
custom = mk_list_entry(head, struct flb_custom_plugin, _head);
67+
if(custom->cb_destroy) {
68+
custom->cb_destroy(custom);
69+
}
6770
mk_list_del(&custom->_head);
6871
flb_free(custom);
6972
}

include/fluent-bit/flb_storage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,6 @@ struct flb_storage_metrics *flb_storage_metrics_create(struct flb_config *ctx);
8383
/* cmetrics */
8484
int flb_storage_metrics_update(struct flb_config *config, struct flb_storage_metrics *sm);
8585

86+
void flb_storage_chunk_count(struct flb_config *ctx, int *mem_chunks, int *fs_chunks);
87+
8688
#endif

lib/miniz/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(DEFINED PROJECT_NAME)
77
endif()
88

99
if(CMAKE_MINOR_VERSION LESS 12)
10-
project(miniz)
10+
project(miniz C)
1111
# see issue https://gitlab.kitware.com/cmake/cmake/merge_requests/1799
1212
else()
1313
project(miniz C)

plugins/in_forward/fw.c

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ static int in_fw_init(struct flb_input_instance *ins,
358358

359359
static void in_fw_pause(void *data, struct flb_config *config)
360360
{
361+
int ret;
361362
struct flb_in_fw_config *ctx = data;
363+
362364
if (config->is_running == FLB_TRUE) {
363365
/*
364366
* This is the case when we are not in a shutdown phase, but
@@ -367,11 +369,20 @@ static void in_fw_pause(void *data, struct flb_config *config)
367369
* and wait for the ingestion to resume.
368370
*/
369371
flb_input_collector_pause(ctx->coll_fd, ctx->ins);
370-
if (pthread_mutex_lock(&ctx->conn_mutex)) {
371-
fw_conn_del_all(ctx);
372-
ctx->is_paused = FLB_TRUE;
372+
373+
ret = pthread_mutex_lock(&ctx->conn_mutex);
374+
if (ret != 0) {
375+
flb_plg_error(ctx->ins, "cannot lock collector mutex");
376+
return;
377+
}
378+
379+
fw_conn_del_all(ctx);
380+
ctx->is_paused = FLB_TRUE;
381+
ret = pthread_mutex_unlock(&ctx->conn_mutex);
382+
if (ret != 0) {
383+
flb_plg_error(ctx->ins, "cannot unlock collector mutex");
384+
return;
373385
}
374-
pthread_mutex_unlock(&ctx->conn_mutex);
375386
}
376387

377388
/*
@@ -388,13 +399,24 @@ static void in_fw_pause(void *data, struct flb_config *config)
388399
}
389400

390401
static void in_fw_resume(void *data, struct flb_config *config) {
402+
int ret;
391403
struct flb_in_fw_config *ctx = data;
404+
392405
if (config->is_running == FLB_TRUE) {
393406
flb_input_collector_resume(ctx->coll_fd, ctx->ins);
394-
if (pthread_mutex_lock(&ctx->conn_mutex)) {
395-
ctx->is_paused = FLB_FALSE;
407+
408+
ret = pthread_mutex_lock(&ctx->conn_mutex);
409+
if (ret != 0) {
410+
flb_plg_error(ctx->ins, "cannot lock collector mutex");
411+
return;
412+
}
413+
414+
ctx->is_paused = FLB_FALSE;
415+
ret = pthread_mutex_unlock(&ctx->conn_mutex);
416+
if (ret != 0) {
417+
flb_plg_error(ctx->ins, "cannot unlock collector mutex");
418+
return;
396419
}
397-
pthread_mutex_unlock(&ctx->conn_mutex);
398420
}
399421
}
400422

plugins/out_azure_blob/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(src
66
azure_blob_db.c
77
azure_blob_appendblob.c
88
azure_blob_blockblob.c
9+
azure_blob_store.c
910
)
1011

1112
FLB_PLUGIN(out_azure_blob "${src}" "")

0 commit comments

Comments
 (0)