Cherry-pick #24742 to 7.x: Refactor kubernetes autodiscover to avoid skipping short-living pods#25167
Merged
jsoriano merged 1 commit intoelastic:7.xfrom Apr 20, 2021
Merged
Conversation
…lastic#24742) Refactor logic in kubernetes autodiscover that decides when to generate events to try to address issues with short-living containers. Kubernetes autodiscover can generate events without network information now (without host or port/ports). This allows to generate events for pods that haven't started yet, or have succeeded/failed before generating a running event. These events still include the container id, so they can be used to collect logs. Still, no start event is generated if no pod ip and no container ids are available. Some helpers have been added to obtain relevant information from pods and their containers. Some additional small refactors are done to improve readability. (cherry picked from commit b4b6e6e)
Contributor
|
Pinging @elastic/integrations (Team:Integrations) |
Contributor
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #24742 to 7.x branch. Original message:
What does this PR do?
Refactor logic in kubernetes autodiscover that decides when to generate events to try to address #22718.
Kubernetes autodiscover can generate events without network information now (without
hostorport/ports). This allows to generate events for pods that haven't started yet, or have succeeded/failed before generating a running event. These events still include the container id, so they can be used to collect logs. Still, no start event is generated if no pod ip and no container ids are available.Some helpers have been added to obtain relevant information from pods and their containers.
Some additional small refactors are done to improve readability.
Why is it important?
Current logic is checking similar things at the pod and container levels, try to simplify this logic focusing in containers only.
No matter what is the state of the pod, if there is a container running or trying to run, even if it is unhealthy, some configuration should be generated, so logs can be collected.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
data.host.This is logged at the debug level:
data.hostordata.ports.data.ports.*doesn't seem to be working, check if this is a regression. Named ports were not added to container events. They are now.Author's notes for the future
data.portsis not included in container-level events, so it doesn't work when conditions for specific containers are used.How to test this PR locally
kubectl run --image=redis redis -- echo foo).Related issues
Use cases
Collect logs from containers in short-living or failing pods.