-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[add_cloud_metadata] Remove logger for AWS/EC2 #36829
[add_cloud_metadata] Remove logger for AWS/EC2 #36829
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
if err != nil { | ||
logger.Warnf("error fetching cluster name metadata: %s.", err) | ||
} | ||
clusterName, _ := fetchEC2ClusterNameTag(awsConfig, instanceIdentity.InstanceIdentityDocument.InstanceID) |
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.
We probably should not ignore the error here. When we do collect tags from an ec2 instance, this error should be surfaced. For example user might not have DescribeTags permission configured properly.
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.
We should keep this warning here. Also for the original log, since we removed the logger.Warnf("error fetching EC2 Identity Document: %s.", err)
line and it has a return
there at line 88, this warning should not matter when EC2 is not the proper cloud metadata source.
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.
You're right @kaiyan-sheng , I added the log message again to this one
Hey @constanca-m thanks for working on this! I think instead of removing the logger, maybe we should reconsider the logic in |
I had a look at this again. The main difference between this provider and the others is the generic fetcher (thanks @tetianakravchenko for pointing it out). To give context, the way The responses (timeouts and errors of each provider) are taken care of here:
If we have no providers (meaning that all of them timed out with the request), we end up doing nothing. Otherwise we take care of each result. Since the logs are going to
And this should solve the loggers problem. What do you think @gizas @tetianakravchenko @kaiyan-sheng ? |
/test |
@@ -22,13 +22,14 @@ import ( | |||
"fmt" | |||
"net/http" | |||
|
|||
"github.com/elastic/elastic-agent-libs/logp" |
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.
nit: I dont think we need to move this import around
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.
We need to move it around because of the errors of one of the tests. They force it to be sorted through the tool goimport
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 for the write up, looks good to me (besides the lib import)!
* Remove logger. * Add error message. * Add log message (cherry picked from commit d66a000) # Conflicts: # libbeat/processors/add_cloud_metadata/provider_aws_ec2.go
* Remove logger. * Add error message. * Add log message (cherry picked from commit d66a000)
* Remove logger. * Add error message. * Add log message (cherry picked from commit d66a000) Co-authored-by: Constança Manteigas <[email protected]>
* Remove logger. * Add error message. * Add log message
What
Remove the logger for the provider AWS/EC2 in
add_cloud_metadata
.Details
add_cloud_metadata
is enabled by default. When the provider AWS/EC2 is setup we see this message at all times, even when we are not using AWS/EC2:This change was introduced by this PR: #28285.
It is happening because when creating the provider, we call this function:
beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go
Line 73 in e322104
And then we try to create each provider of the list:
beats/libbeat/processors/add_cloud_metadata/providers.go
Line 115 in e322104
The problem comes when this function is called. We have a logger that will start outputting warnings:
beats/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go
Line 78 in e322104
If we check the other providers' files (
provider_*.go
), we can check that none of them are using loggers inside theirCreate
.The easiest solution for now is just to delete the loggers.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
The easiest way is to:
Related issues
add_cloud_metadata
produces errors running in non-cloud elastic-agent install #36018.Logs
It is no longer present in the logs.