Skip to content

Commit

Permalink
out_blob: consider auto_create_container (#9457)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
uristernik authored Oct 31, 2024
1 parent e8feef3 commit 104aceb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugins/out_azure_blob/azure_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 104aceb

Please sign in to comment.