From 88f44c6c8031794d5d75d2ef424513942683a0a2 Mon Sep 17 00:00:00 2001 From: Uri Sternik Date: Fri, 4 Oct 2024 10:59:59 +0300 Subject: [PATCH 1/2] Consider auto_create_container when ensuring container exist 1. Today we are not considering this setting 2. Changing the behaviour that setting auto_create_container to false should return FLB_TRUE. If auto_create_container=false return FLB_FALSE, fluent-bit will never flush data to storage account, it will retry and eventually fail. Signed-off-by: Uri Sternik --- plugins/out_azure_blob/azure_blob.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index ec82ee9278c..83bb288595a 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -517,7 +517,9 @@ static int create_container(struct flb_azure_blob *ctx, char *name) /* * Check that the container exists, if it doesn't and the configuration property * auto_create_container is enabled, it will send a request to create it. If it - * could not be created or auto_create_container is disabled, it returns FLB_FALSE. + * could not be created, it returns FLB_FALSE. + * If auto_create_container is disabled, it will return FLB_TRUE assuming the container + * already exists. */ static int ensure_container(struct flb_azure_blob *ctx) { @@ -528,8 +530,15 @@ static int ensure_container(struct flb_azure_blob *ctx) struct flb_http_client *c; struct flb_connection *u_conn; + if (!ctx->auto_create_container) { + flb_plg_info(ctx->ins, "auto_create_container is disabled, assuming container '%s' already exists", + ctx->container_name); + return FLB_TRUE; + } + uri = azb_uri_ensure_or_create_container(ctx); if (!uri) { + flb_plg_error(ctx->ins, "cannot create container URI"); return FLB_FALSE; } @@ -582,8 +591,17 @@ static int ensure_container(struct flb_azure_blob *ctx) return ret; } else if (status == 200) { + flb_plg_info(ctx->ins, "container '%s' already exists", ctx->container_name); return FLB_TRUE; + } + else if (status == 403) { + flb_plg_error(ctx->ins, "failed getting container '%s', access denied", + ctx->container_name); + return FLB_FALSE; } + + flb_plg_debug(ctx->ins, "get container request failed, status=%i", + status); return FLB_FALSE; } @@ -979,6 +997,8 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk, */ ret = ensure_container(ctx); if (ret == FLB_FALSE) { + flb_plg_error(ctx->ins, "cannot ensure container '%s' exists", + ctx->container_name); FLB_OUTPUT_RETURN(FLB_RETRY); } From e2aaa87f938cbc15e713f1e61e75eab82d620517 Mon Sep 17 00:00:00 2001 From: Uri Sternik Date: Tue, 22 Oct 2024 11:35:47 +0300 Subject: [PATCH 2/2] Remove redundant log Signed-off-by: Uri Sternik --- plugins/out_azure_blob/azure_blob.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 83bb288595a..f670de5caee 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -600,7 +600,7 @@ static int ensure_container(struct flb_azure_blob *ctx) return FLB_FALSE; } - flb_plg_debug(ctx->ins, "get container request failed, status=%i", + flb_plg_error(ctx->ins, "get container request failed, status=%i", status); return FLB_FALSE; @@ -997,8 +997,6 @@ static void cb_azure_blob_flush(struct flb_event_chunk *event_chunk, */ ret = ensure_container(ctx); if (ret == FLB_FALSE) { - flb_plg_error(ctx->ins, "cannot ensure container '%s' exists", - ctx->container_name); FLB_OUTPUT_RETURN(FLB_RETRY); }