From 104acebbd7da88b70a38908ea2ece92d1bdb7a8b Mon Sep 17 00:00:00 2001 From: Uri Sternik <39219232+uristernik@users.noreply.github.com> Date: Fri, 1 Nov 2024 00:13:17 +0200 Subject: [PATCH] out_blob: consider auto_create_container (#9457) * 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 <uri.sternik@wiz.io> --- plugins/out_azure_blob/azure_blob.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 98a1ff8807f..c13da85204d 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_error(ctx->ins, "get container request failed, status=%i", + status); return FLB_FALSE; }