Skip to content

Commit

Permalink
Allow 0 as Retry_Limit to disable retrying (fluent#3219)
Browse files Browse the repository at this point in the history
* output: define unlimited/none retry configurtion constant

Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>

* engine: support no retry configuration(fluent#3190)

Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>

* sosreport: use FLB_OUT_RETRY_UNLIMITED define

Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>

* output: set default value when invalid retry_limit is set

Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>

* output: support no_retries/no_limits as retry_limits value

Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
  • Loading branch information
nokute78 authored and DrewZhang13 committed May 3, 2021
1 parent 8b00df6 commit 7c46b02
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/fluent-bit/flb_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ struct flb_output_plugin {
struct mk_list _head;
};

// constants for retry_limit
#define FLB_OUT_RETRY_UNLIMITED -1
#define FLB_OUT_RETRY_NONE 0

/*
* Each initialized plugin must have an instance, same plugin may be
* loaded more than one time.
Expand Down
11 changes: 11 additions & 0 deletions src/flb_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ static inline int handle_output_event(flb_pipefd_t fd, struct flb_config *config
flb_task_users_dec(task, FLB_TRUE);
}
else if (ret == FLB_RETRY) {
if (ins->retry_limit == FLB_OUT_RETRY_NONE) {
flb_info("[engine] chunk '%s' is not retried (no retry config): "
"task_id=%i, input=%s > output=%s (out_id=%i)",
flb_input_chunk_get_name(task->ic),
task_id,
flb_input_name(task->i_ins),
flb_output_name(ins), out_id);
flb_task_users_dec(task, FLB_TRUE);
return 0;
}

/* Create a Task-Retry */
retry = flb_task_retry_create(task, ins);
if (!retry) {
Expand Down
15 changes: 12 additions & 3 deletions src/flb_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,18 +598,27 @@ int flb_output_set_property(struct flb_output_instance *ins,
}
else if (prop_key_check("retry_limit", k, len) == 0) {
if (tmp) {
if (strcasecmp(tmp, "false") == 0 ||
if (strcasecmp(tmp, "no_limits") == 0 ||
strcasecmp(tmp, "false") == 0 ||
strcasecmp(tmp, "off") == 0) {
/* No limits for retries */
ins->retry_limit = -1;
ins->retry_limit = FLB_OUT_RETRY_UNLIMITED;
}
else if (strcasecmp(tmp, "no_retries") == 0) {
ins->retry_limit = FLB_OUT_RETRY_NONE;
}
else {
ins->retry_limit = atoi(tmp);
if (ins->retry_limit <= 0) {
flb_warn("[config] invalid retry_limit. set default.");
/* set default when input is invalid number */
ins->retry_limit = 1;
}
}
flb_sds_destroy(tmp);
}
else {
ins->retry_limit = 0;
ins->retry_limit = 1;
}
}
else if (strncasecmp("net.", k, 4) == 0 && tmp) {
Expand Down
2 changes: 1 addition & 1 deletion src/flb_sosreport.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ int flb_sosreport(struct flb_config *config)
ins_out->tls_key_passwd ? "*****" : "(not set)");
}
#endif
if (ins_out->retry_limit == -1) {
if (ins_out->retry_limit == FLB_OUT_RETRY_UNLIMITED) {
printf(" Retry Limit\t\tno limit\n");
}
else {
Expand Down

0 comments on commit 7c46b02

Please sign in to comment.