Skip to content

Commit

Permalink
out_azure_blob: fixed missing parameter detection
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich authored and edsiper committed Oct 21, 2024
1 parent 30eb89e commit 8f1fd00
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/out_azure_blob/azure_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,12 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk
struct flb_log_event_decoder log_decoder;
struct flb_log_event log_event;

if (ctx->db == NULL) {
flb_plg_error(ctx->ins, "Cannot process blob because this operation requires a database.");

return -1;
}

ret = flb_log_event_decoder_init(&log_decoder,
(char *) event_chunk->data,
event_chunk->size);
Expand Down Expand Up @@ -724,6 +730,10 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context
flb_sched_timer_cb_coro_return();
}

if (ctx->db == NULL) {
flb_sched_timer_cb_coro_return();
}

info->active_upload = FLB_TRUE;

/*
Expand Down
5 changes: 5 additions & 0 deletions plugins/out_azure_blob/azure_blob_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in
return NULL;
}

if (ctx->account_name == NULL) {
flb_plg_error(ctx->ins, "'account_name' has not been set");
return NULL;
}

if (ctx->configuration_endpoint_url != NULL) {
ret = flb_azure_blob_apply_remote_configuration(ctx);

Expand Down
5 changes: 5 additions & 0 deletions plugins/out_azure_blob/azure_blob_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path)

int azb_db_close(struct flb_azure_blob *ctx)
{
if (ctx->db == NULL) {
return 0;
}

/* finalize prepared statements */
sqlite3_finalize(ctx->stmt_insert_file);
sqlite3_finalize(ctx->stmt_delete_file);
Expand All @@ -272,6 +276,7 @@ int azb_db_close(struct flb_azure_blob *ctx)
sqlite3_finalize(ctx->stmt_get_oldest_file_with_parts);

pthread_mutex_destroy(&ctx->db_lock);

return flb_sqldb_close(ctx->db);
}

Expand Down

0 comments on commit 8f1fd00

Please sign in to comment.