Skip to content

Commit

Permalink
storage: recreate cio_stream if storage type is different(#8259) (#8290)
Browse files Browse the repository at this point in the history
* storage: recreate cio_stream if storage type is different(#8259)

cio_load creates storage stream if directory exists.
It prevents to create memory stream by input plugins.
This patch is to recreate stream if the type is different.

Signed-off-by: Takahiro Yamashita <[email protected]>

* storage: modify log message

Signed-off-by: Takahiro Yamashita <[email protected]>

---------

Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored Jan 10, 2024
1 parent 9caaf60 commit 309d961
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/flb_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,22 @@ int flb_storage_input_create(struct cio_ctx *cio,
return -1;
}
}
else if (stream->type != cio_storage_type) {
flb_debug("[storage] storage type mismatch. input type=%s",
flb_storage_get_type(in->storage_type));
if (stream->type == FLB_STORAGE_FS) {
flb_warn("[storage] Need to remove '%s/%s' if it is empty", cio->options.root_path, in->name);
}

cio_stream_destroy(stream);
stream = cio_stream_create(cio, in->name, cio_storage_type);
if (!stream) {
flb_error("[storage] cannot create stream for instance %s",
in->name);
return -1;
}
flb_info("[storage] re-create stream type=%s", flb_storage_get_type(in->storage_type));
}

/* allocate storage context for the input instance */
si = flb_malloc(sizeof(struct flb_storage_input));
Expand Down

0 comments on commit 309d961

Please sign in to comment.