-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter_ecs: fix multiple bugs and make retries configurable #6589
Conversation
Signed-off-by: Wesley Pettit <[email protected]>
plugins/filter_ecs/ecs.c
Outdated
{ | ||
FLB_CONFIG_MAP_INT, "agent_endpoint_retries", FLB_ECS_FILTER_METADATA_RETRIES, | ||
0, FLB_TRUE, offsetof(struct flb_filter_ecs, agent_endpoint_retries), | ||
"Number of retries for failed metadata requsts to ECS Agent Introspection " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling
6f6b06f
to
e207bba
Compare
It appears that this code is segfaulting during unit tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config map default value must be of type string.
This PR's code currently segfaults here:
Lines 156 to 179 in eceeb5f
/* | |
* Given a 'value', lookup for variables, if found, return a new composed | |
* sds string. | |
*/ | |
flb_sds_t flb_env_var_translate(struct flb_env *env, const char *value) | |
{ | |
int i; | |
int len; | |
int v_len; | |
int e_len; | |
int pre_var; | |
int have_var = FLB_FALSE; | |
const char *env_var = NULL; | |
char *v_start = NULL; | |
char *v_end = NULL; | |
char tmp[64]; | |
flb_sds_t buf; | |
flb_sds_t s; | |
if (!value) { | |
return NULL; | |
} | |
len = strlen(value); |
@@ -1694,6 +1694,15 @@ static struct flb_config_map config_map[] = { | |||
"Defaults to 51678" | |||
}, | |||
|
|||
{ | |||
FLB_CONFIG_MAP_INT, "agent_endpoint_retries", FLB_ECS_FILTER_METADATA_RETRIES, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config_map
entry def_value
must be a string
flb_sds_t def_value; /* default value */ |
See NightFall for an example
FLB_CONFIG_MAP_INT, "tls.debug", "0", |
The string value may be autoconverted to one of the FLB_CONFIG_MAP_INT type here:
fluent-bit/src/flb_config_map.c
Lines 271 to 273 in 1532471
* As an additional step, it populate the 'value' field using the given default | |
* value if any. Note that default values are strings so they are processed | |
* to fit into the proper data type of 'value'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested edit: Revise FLB_ECS_FILTER_METADATA_RETRIES from 2 to "2"
fluent-bit/plugins/filter_ecs/ecs.h
Line 33 in e207bba
#define FLB_ECS_FILTER_METADATA_RETRIES 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
e207bba
to
cc79103
Compare
cc79103
to
f0401f6
Compare
f0401f6
to
c5e1a7c
Compare
plugins/filter_ecs/ecs.c
Outdated
@@ -1369,14 +1369,14 @@ static int is_tag_marked_failed(struct flb_filter_ecs *ctx, | |||
const char *tag, int tag_len) | |||
{ | |||
int ret; | |||
int val = 0; | |||
int *val = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initializing to 0 instead of NULL...
Signed-off-by: Wesley Pettit <[email protected]>
Signed-off-by: Wesley Pettit <[email protected]>
c5e1a7c
to
aa173e0
Compare
@@ -1393,7 +1393,7 @@ static void mark_tag_failed(struct flb_filter_ecs *ctx, | |||
|
|||
ret = flb_hash_get(ctx->failed_metadata_request_tags, | |||
tag, tag_len, | |||
(void *) val, &val_size); | |||
(void **) &val, &val_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code below is still buggy, need to alloc memory for hash table to copy over in all cases
Signed-off-by: Wesley Pettit <[email protected]>
c8a3490
to
0f05bce
Compare
Ran tests with valgrind and that's how I came up with the other fix... flb_hash doesn't work the way I thought it would/I didn't read that code closely enough:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
These commits were merged with: https://github.com/fluent/fluent-bit/pull/6614/commits |
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.