-
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
Don't collect empty ip addresses in docker container metricset #11247
Conversation
Docker containers can have empty ip addresses if they are running in host network mode or if they are stopped. Collecting lists with empty addresses can make type mapping to fail when trying to store them as ip addresses.
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.
LGTM
@@ -71,7 +71,9 @@ func eventMapping(r mb.ReporterV2, cont *types.Container, dedot bool) { | |||
func extractIPAddresses(networks *types.SummaryNetworkSettings) []string { | |||
ipAddresses := make([]string, 0, len(networks.Networks)) |
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.
With this change ipAddresses
is now not anymore len(networks.Networks)
. Is it mainly in testing that it might be empty or a common case? Thinking which use case we should optimise for.
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.
I though about this and I think that in most of the cases ipAddresses
is still going to be len(networks.Networks)
.
The most common case where this is not going to be true is when the container is using the host network, in that case we would be creating an array of capacity one that we are not going to use.
…ic#11247) Docker containers can have empty ip addresses if they are running in host network mode or if they are stopped. Collecting lists with empty addresses can make type mapping to fail when trying to store them as ip addresses. Fix elastic#11225 (cherry picked from commit 258c1c8)
Docker containers can have empty ip addresses if they are running in
host network mode or if they are stopped. Collecting lists with empty
addresses can make type mapping to fail when trying to store them as ip
addresses.
It only affects 7.0 because before these ip addresses were of type
keyword
.Fix #11225