From 3b31567cb7533640a2a882178cd6639a657b2af8 Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Fri, 2 May 2025 13:18:28 +0200 Subject: [PATCH 1/3] in_blob: fix compilation if FLB_SQLDB (sqlite3) is disabled Signed-off-by: Thomas Devoogdt --- plugins/in_blob/blob.c | 8 +++++++- plugins/in_blob/blob.h | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/in_blob/blob.c b/plugins/in_blob/blob.c index c3fb8918e62..e9ab9645f19 100644 --- a/plugins/in_blob/blob.c +++ b/plugins/in_blob/blob.c @@ -40,9 +40,12 @@ #include #include "blob.h" -#include "blob_db.h" #include "blob_file.h" +#ifdef FLB_HAVE_SQLDB +#include "blob_db.h" +#endif + #include "win32_glob.c" /* Define missing GLOB_TILDE if not exists */ @@ -739,7 +742,10 @@ static int in_blob_exit(void *in_context, struct flb_config *config) return 0; } +#ifdef FLB_HAVE_SQLDB blob_db_close(ctx); +#endif + blob_file_list_remove_all(ctx); flb_log_event_encoder_destroy(ctx->log_encoder); flb_free(ctx); diff --git a/plugins/in_blob/blob.h b/plugins/in_blob/blob.h index 5f18ca23b93..0333dbddf6e 100644 --- a/plugins/in_blob/blob.h +++ b/plugins/in_blob/blob.h @@ -21,10 +21,13 @@ #define FLB_IN_BLOB_H #include -#include #include #include +#ifdef FLB_HAVE_SQLDB +#include +#endif + #define POST_UPLOAD_ACTION_NONE 0 #define POST_UPLOAD_ACTION_DELETE 1 #define POST_UPLOAD_ACTION_EMIT_LOG 2 From 90dca596e4d2b8e5a95ccb1a379962fba98dec93 Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Fri, 2 May 2025 13:25:57 +0200 Subject: [PATCH 2/3] filter_checklist: fix compilation if FLB_SQLDB (sqlite3) is disabled Signed-off-by: Thomas Devoogdt --- plugins/filter_checklist/checklist.c | 13 ++++++++++++- plugins/filter_checklist/checklist.h | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/filter_checklist/checklist.c b/plugins/filter_checklist/checklist.c index 210f26065ca..60a254a8c51 100644 --- a/plugins/filter_checklist/checklist.c +++ b/plugins/filter_checklist/checklist.c @@ -21,13 +21,13 @@ #include #include #include -#include #include #include #include "checklist.h" #include +#ifdef FLB_HAVE_SQLDB static int db_init(struct checklist *ctx) { int ret; @@ -124,6 +124,7 @@ static int db_check(struct checklist *ctx, char *buf, size_t size) return match; } +#endif static int load_file_patterns(struct checklist *ctx) { @@ -175,9 +176,11 @@ static int load_file_patterns(struct checklist *ctx) if (ctx->mode == CHECK_EXACT_MATCH) { ret = flb_hash_table_add(ctx->ht, buf, len, "", 0); } +#ifdef FLB_HAVE_SQLDB else if (ctx->mode == CHECK_PARTIAL_MATCH) { ret = db_insert(ctx, buf, len); } +#endif if (ret >= 0) { flb_plg_debug(ctx->ins, "file list: line=%i adds value='%s'", line, buf); @@ -209,9 +212,11 @@ static int init_config(struct checklist *ctx) if (strcasecmp(tmp, "exact") == 0) { ctx->mode = CHECK_EXACT_MATCH; } +#ifdef FLB_HAVE_SQLDB else if (strcasecmp(tmp, "partial") == 0) { ctx->mode = CHECK_PARTIAL_MATCH; } +#endif } if (ctx->mode == CHECK_EXACT_MATCH) { @@ -223,12 +228,14 @@ static int init_config(struct checklist *ctx) return -1; } } +#ifdef FLB_HAVE_SQLDB else if (ctx->mode == CHECK_PARTIAL_MATCH) { ret = db_init(ctx); if (ret < 0) { return -1; } } +#endif /* record accessor pattern / key name */ ctx->ra_lookup_key = flb_ra_create(ctx->lookup_key, FLB_TRUE); @@ -504,9 +511,11 @@ static int cb_checklist_filter(const void *data, size_t bytes, found = FLB_TRUE; } } +#ifdef FLB_HAVE_SQLDB else if (ctx->mode == CHECK_PARTIAL_MATCH) { found = db_check(ctx, cmp_buf, cmp_size); } +#endif if (cmp_buf && cmp_buf != (char *) rval->o.via.str.ptr) { flb_free(cmp_buf); @@ -592,11 +601,13 @@ static int cb_exit(void *data, struct flb_config *config) flb_hash_table_destroy(ctx->ht); } +#ifdef FLB_HAVE_SQLDB if (ctx->db) { sqlite3_finalize(ctx->stmt_insert); sqlite3_finalize(ctx->stmt_check); flb_sqldb_close(ctx->db); } +#endif flb_free(ctx); return 0; diff --git a/plugins/filter_checklist/checklist.h b/plugins/filter_checklist/checklist.h index 5fb797c5459..f73e0d3b284 100644 --- a/plugins/filter_checklist/checklist.h +++ b/plugins/filter_checklist/checklist.h @@ -21,14 +21,19 @@ #define FLB_FILTER_CHECK_H #include -#include #include #include +#ifdef FLB_HAVE_SQLDB +#include +#endif + #define LINE_SIZE 2048 #define CHECK_HASH_TABLE_SIZE 100000 #define CHECK_EXACT_MATCH 0 /* exact string match */ +#ifdef FLB_HAVE_SQLDB #define CHECK_PARTIAL_MATCH 1 /* partial match */ +#endif /* plugin context */ struct checklist { @@ -41,9 +46,11 @@ struct checklist { struct mk_list *records; /* internal */ +#ifdef FLB_HAVE_SQLDB struct flb_sqldb *db; sqlite3_stmt *stmt_insert; sqlite3_stmt *stmt_check; +#endif struct flb_hash_table *ht; struct flb_record_accessor *ra_lookup_key; struct flb_filter_instance *ins; From 24532cdc88c8da689fb0be7d22f2506404227744 Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Fri, 2 May 2025 13:49:00 +0200 Subject: [PATCH 3/3] out_azure_blob: fix compilation if FLB_SQLDB (sqlite3) is disabled Signed-off-by: Thomas Devoogdt --- include/fluent-bit/flb_event.h | 3 +++ plugins/out_azure_blob/azure_blob.c | 18 ++++++++++++++++-- plugins/out_azure_blob/azure_blob.h | 3 +++ plugins/out_azure_blob/azure_blob_blockblob.c | 1 + plugins/out_azure_blob/azure_blob_conf.c | 10 +++++++++- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/fluent-bit/flb_event.h b/include/fluent-bit/flb_event.h index ba148820cb3..430f0e861a3 100644 --- a/include/fluent-bit/flb_event.h +++ b/include/fluent-bit/flb_event.h @@ -29,7 +29,10 @@ #define FLB_EVENT_TYPE_METRICS FLB_INPUT_CHUNK_TYPE_METRICS #define FLB_EVENT_TYPE_TRACES FLB_INPUT_CHUNK_TYPE_TRACES #define FLB_EVENT_TYPE_PROFILES FLB_INPUT_CHUNK_TYPE_PROFILES + +#ifdef FLB_HAVE_SQLDB #define FLB_EVENT_TYPE_BLOBS FLB_INPUT_CHUNK_TYPE_BLOBS +#endif #define FLB_EVENT_TYPE_HAS_TRACE FLB_INPUT_CHUNK_HAS_TRACE diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 8d2b8bcea79..214d48e3b70 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -34,13 +33,16 @@ #include #include "azure_blob.h" -#include "azure_blob_db.h" #include "azure_blob_uri.h" #include "azure_blob_conf.h" #include "azure_blob_appendblob.h" #include "azure_blob_blockblob.h" #include "azure_blob_http.h" +#ifdef FLB_HAVE_SQLDB +#include "azure_blob_db.h" +#endif + #define CREATE_BLOB 1337 /* thread_local_storage for workers */ @@ -151,6 +153,7 @@ static int create_blob(struct flb_azure_blob *ctx, char *name) return FLB_OK; } +#ifdef FLB_HAVE_SQLDB static int delete_blob(struct flb_azure_blob *ctx, char *name) { int ret; @@ -225,6 +228,7 @@ static int delete_blob(struct flb_azure_blob *ctx, char *name) flb_upstream_conn_release(u_conn); return FLB_OK; } +#endif static int http_send_blob(struct flb_config *config, struct flb_azure_blob *ctx, flb_sds_t ref_name, @@ -380,11 +384,13 @@ static int send_blob(struct flb_config *config, uri = azb_block_blob_uri(ctx, tag, block_id, ms); ref_name = flb_sds_printf(&ref_name, "file=%s.%" PRIu64, name, ms); } +#ifdef FLB_HAVE_SQLDB else if (event_type == FLB_EVENT_TYPE_BLOBS) { block_id = azb_block_blob_id_blob(ctx, name, part_id); uri = azb_block_blob_uri(ctx, name, block_id, 0); ref_name = flb_sds_printf(&ref_name, "file=%s:%" PRIu64, name, part_id); } +#endif } if (!uri) { @@ -416,10 +422,12 @@ static int send_blob(struct flb_config *config, return FLB_ERROR; } } +#ifdef FLB_HAVE_SQLDB else if (event_type == FLB_EVENT_TYPE_BLOBS) { payload_buf = data; payload_size = bytes; } +#endif ret = http_send_blob(config, ctx, ref_name, uri, block_id, event_type, payload_buf, payload_size); flb_plg_debug(ctx->ins, "http_send_blob()=%i", ret); @@ -635,6 +643,7 @@ static int cb_azure_blob_init(struct flb_output_instance *ins, return 0; } +#ifdef FLB_HAVE_SQLDB static int blob_chunk_register_parts(struct flb_azure_blob *ctx, uint64_t file_id, size_t total_size) { int ret; @@ -1034,6 +1043,7 @@ static int azb_timer_create(struct flb_azure_blob *ctx) return 0; } +#endif static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk, struct flb_output_flush *out_flush, @@ -1081,6 +1091,7 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk, } } } +#ifdef FLB_HAVE_SQLDB else if (event_chunk->type == FLB_EVENT_TYPE_BLOBS) { /* * For Blob types, we use the flush callback to enqueue the file, then cb_azb_blob_file_upload() @@ -1091,6 +1102,7 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk, FLB_OUTPUT_RETURN(FLB_RETRY); } } +#endif /* FLB_RETRY, FLB_OK, FLB_ERROR */ FLB_OUTPUT_RETURN(ret); @@ -1129,11 +1141,13 @@ static int cb_worker_init(void *data, struct flb_config *config) FLB_TLS_SET(worker_info, info); } +#ifdef FLB_HAVE_SQLDB ret = azb_timer_create(ctx); if (ret == -1) { flb_plg_error(ctx->ins, "failed to create upload timer"); return -1; } +#endif return 0; } diff --git a/plugins/out_azure_blob/azure_blob.h b/plugins/out_azure_blob/azure_blob.h index 361e348de79..c85cb2c7481 100644 --- a/plugins/out_azure_blob/azure_blob.h +++ b/plugins/out_azure_blob/azure_blob.h @@ -23,7 +23,10 @@ #include #include #include + +#ifdef FLB_HAVE_SQLDB #include +#endif /* Content-Type */ #define AZURE_BLOB_CT "Content-Type" diff --git a/plugins/out_azure_blob/azure_blob_blockblob.c b/plugins/out_azure_blob/azure_blob_blockblob.c index 5acb03689b9..4ed7fb88cc6 100644 --- a/plugins/out_azure_blob/azure_blob_blockblob.c +++ b/plugins/out_azure_blob/azure_blob_blockblob.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/plugins/out_azure_blob/azure_blob_conf.c b/plugins/out_azure_blob/azure_blob_conf.c index d9c6ee68837..3ccecc1884a 100644 --- a/plugins/out_azure_blob/azure_blob_conf.c +++ b/plugins/out_azure_blob/azure_blob_conf.c @@ -20,10 +20,14 @@ #include #include #include +#include #include "azure_blob.h" #include "azure_blob_conf.h" + +#ifdef FLB_HAVE_SQLDB #include "azure_blob_db.h" +#endif #include #include @@ -748,6 +752,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in } } +#ifdef FLB_HAVE_SQLDB /* database file for blob signal handling */ if (ctx->database_file) { ctx->db = azb_db_open(ctx, ctx->database_file); @@ -757,6 +762,7 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in } pthread_mutex_init(&ctx->file_upload_commit_file_parts, NULL); +#endif flb_plg_info(ctx->ins, "account_name=%s, container_name=%s, blob_type=%s, emulator_mode=%s, endpoint=%s, auth_type=%s", @@ -812,7 +818,9 @@ void flb_azure_blob_conf_destroy(struct flb_azure_blob *ctx) flb_upstream_destroy(ctx->u); } - +#ifdef FLB_HAVE_SQLDB azb_db_close(ctx); +#endif + flb_free(ctx); }