-
Notifications
You must be signed in to change notification settings - Fork 813
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
[autodiscovery] annotations with multi instances bug #3478
Conversation
"""Add container tags to instance templates and build a | ||
dict from template variable names and their values.""" | ||
var_values = {} | ||
c_image = state.inspect_container(c_id).get('Config', {}).get('Image', '') | ||
|
||
# add default tags to the instance | ||
# add only default c_tags to the instance to avoid duplicate tags from conf | ||
tags = copy.copy(c_tags) |
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.
Good catch! Thanks for digging in this issue.
If that's the only place we use it I'd rather not import copy and do tags = c_tags[:]
instead. It will create a new list with all the elements of c_tags.
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.
Tested with @hkaj's suggestion and it fixed the issue I had with way too much tags on my "query" metrics for the mysql integration configured in multi-instances mode via k8s annotations.
if c_tags: | ||
tags = c_tags[:] # shallow copy of the c_tags array | ||
else | ||
tags = [] |
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.
what about this?
def _fill_tpl(self, state, c_id, instance_tpl, variables, c_tags=[]):
...
tags = c_tags[:]
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.
👌
53a8ba9
to
cf4f8a9
Compare
d7806af
to
1ffbbc5
Compare
…to check level tags be added to container level tags array
1ffbbc5
to
0e6ff98
Compare
What does this PR do?
Bug fix of #3341
Annotations with multi instances configuration leads to check level tags be added to the container level tags array.
While adding container tags with this method, performs a shallow copy of the container tag array to avoid adding tags from the previous instance ( which would come from this for loop), contains its check tags.
Motivation
Issue encountered by a customer.
Testing Guidelines
Instantiate a pod with annotations containing several instances (along the lines of this example)
The agent will detect the check but it will add the config level tags to the container level ones.
e.g.:
As per the above pod yaml, this metric should only be tagged with
dbinstanceidentifier:dbi2
.With the change, we have: