Skip to content

Commit 28fabd0

Browse files
committed
out_s3: Address revire comments
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 6d712df commit 28fabd0

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

plugins/out_s3/s3.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,21 @@ static struct flb_aws_header *get_content_encoding_header(int compression_type)
100100
.val = "gzip",
101101
.val_len = 4,
102102
};
103-
103+
104104
static struct flb_aws_header zstd_header = {
105105
.key = "Content-Encoding",
106106
.key_len = 16,
107107
.val = "zstd",
108108
.val_len = 4,
109109
};
110-
110+
111111
static struct flb_aws_header snappy_header = {
112112
.key = "Content-Encoding",
113113
.key_len = 16,
114114
.val = "snappy",
115115
.val_len = 6,
116116
};
117-
117+
118118
switch (compression_type) {
119119
case FLB_AWS_COMPRESS_GZIP:
120120
return &gzip_header;
@@ -199,7 +199,7 @@ int create_headers(struct flb_s3 *ctx, char *body_md5,
199199
if (ctx->content_type != NULL) {
200200
headers_len++;
201201
}
202-
if (ctx->compression == FLB_AWS_COMPRESS_GZIP ||
202+
if (ctx->compression == FLB_AWS_COMPRESS_GZIP ||
203203
ctx->compression == FLB_AWS_COMPRESS_ZSTD ||
204204
ctx->compression == FLB_AWS_COMPRESS_SNAPPY) {
205205
headers_len++;
@@ -231,7 +231,7 @@ int create_headers(struct flb_s3 *ctx, char *body_md5,
231231
s3_headers[n].val_len = strlen(ctx->content_type);
232232
n++;
233233
}
234-
if (ctx->compression == FLB_AWS_COMPRESS_GZIP ||
234+
if (ctx->compression == FLB_AWS_COMPRESS_GZIP ||
235235
ctx->compression == FLB_AWS_COMPRESS_ZSTD ||
236236
ctx->compression == FLB_AWS_COMPRESS_SNAPPY) {
237237
encoding_header = get_content_encoding_header(ctx->compression);
@@ -847,7 +847,7 @@ static int cb_s3_init(struct flb_output_instance *ins,
847847
"total_file_size is less than 10 MB, will use PutObject API");
848848
ctx->use_put_object = FLB_TRUE;
849849
}
850-
850+
851851
if (ctx->use_put_object == FLB_FALSE) {
852852
/* upload_chunk_size */
853853
if (ctx->upload_chunk_size <= 0) {
@@ -1987,7 +1987,8 @@ static void s3_chunk_retry_exhausted_cleanup(struct flb_s3 *ctx,
19871987
ret = s3_store_file_inactive(ctx, chunk_file);
19881988
if (ret < 0) {
19891989
flb_plg_error(ctx->ins,
1990-
"could not quarantine retry-exhausted chunk");
1990+
"could not quarantine, deleting retry-exhausted chunk");
1991+
s3_store_file_delete(ctx, chunk_file);
19911992
return;
19921993
}
19931994

plugins/out_s3/s3_store.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ static int set_files_context(struct flb_s3 *ctx)
215215
struct flb_fstore_stream *fs_stream;
216216
struct flb_fstore_file *fsf;
217217
struct s3_file *s3_file;
218+
ssize_t file_size;
218219

219220
mk_list_foreach(head, &ctx->fs->streams) {
220221
fs_stream = mk_list_entry(head, struct flb_fstore_stream, _head);
@@ -246,6 +247,11 @@ static int set_files_context(struct flb_s3 *ctx)
246247
s3_file->first_log_time = time(NULL);
247248
s3_file->create_time = time(NULL);
248249

250+
file_size = cio_chunk_get_real_size(fsf->chunk);
251+
if (file_size > 0) {
252+
s3_file->size = (size_t) file_size;
253+
}
254+
249255
/* Use fstore opaque 'data' reference to keep our context */
250256
fsf->data = s3_file;
251257
}

0 commit comments

Comments
 (0)