Skip to content
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

Check Pod Autodiscover conditions for node/namespace updates #37338

Closed
2 tasks
gizas opened this issue Dec 7, 2023 · 2 comments
Closed
2 tasks

Check Pod Autodiscover conditions for node/namespace updates #37338

gizas opened this issue Dec 7, 2023 · 2 comments
Assignees
Labels
Team:obs-ds-hosted-services Label for the Observability Hosted Services team

Comments

@gizas
Copy link
Contributor

gizas commented Dec 7, 2023

Context

This issue tries to resolve the #34717
For more details, upon of Node or Namespace event updates, we trigger updates for all pods that are related to the specific resources.

The issue is that many of those updates are not related with the actual metadata information that the watchers are made for. So we need to check which of those updates are the ones that should trigger pod watcher restarts

Solution

We enhance the nodePodupdater function and we also pass the nodeWatcher as a parameter https://github.com/elastic/beats/blob/conditionsonPodupdater/libbeat/autodiscover/providers/kubernetes/pod.go#L156

Then we are able to check whether those updates are releavnt or not in order to trigger a pod update in https://github.com/elastic/elastic-agent-autodiscover/blob/conditionsonPodupdater/kubernetes/eventhandler.go#L236-L245

How to Test

replace github.com/elastic/elastic-agent-autodiscover => /Users/andreasgkizas/elastic/elastic-agent-autodiscover
  • Build filebeat GOOS=linux GOARCH=arm64 go build
  • You can monitor node updates on the background
kubectl proxy &
stdbuf -oL curl -s '127.0.0.1:8001/api/v1/nodes?allowWatchBookmarks=true&watch=true&pretty=false' > nodes.log &
  • Trigger a node with eg.kubectl label nodes kind-control-plane katsoulis=pasole

Definition of Done

  • Test for a longer period of time for node updates
  • Repeat same procedure on namespacePodUpdater
  • Test and verify that metricbeat is not affected. (Reason is to see how autodiscover affects metricbeat)
  • Test with a full Elastic Agent build to see if something is not broken

Testing

  1. Updating label of namespace
kubectl label namespaces default katsoulis3=pasole

Screenshot 2023-12-12 at 4 53 17 PM

  1. Updating label of node
kubectl label node kind-control-plane pas1=pas1

Screenshot 2023-12-13 at 11 46 56 AM

  1. Checking the events of nodes

Metadata Event update in node triggers pod update

Screenshot 2023-12-11 at 2 02 34 PM

Healthcheck Event update in node does not trigger pod update

Screenshot 2023-12-13 at 11 56 28 AM

Relevant link:

Tasks

Preview Give feedback
@gizas gizas self-assigned this Dec 7, 2023
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 7, 2023
@gizas gizas added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Dec 7, 2023
@elasticmachine
Copy link
Collaborator

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@constanca-m
Copy link
Contributor

I ran an environment with these changes.

When I did:

kubectl label node kind-control-plane teste2=teste1

I could see the output:

image

I left filebeat running for longer, and I could not see more updates on pods from the node healthcheck. But if I trigger it again by updating the labels of the node, I can see it the message again for pod update.

It seems to work fine!

gizas added a commit to elastic/elastic-agent-autodiscover that referenced this issue Jan 12, 2024
- Enhancement

## Proposed commit message

- WHAT: Update the PodUpdater fucntion with additonal checks before
actaully triggering Pod watcher restarts
- WHY: There where node and namespace events that dont always inlcude
Metadata changes. We want only update events that change labels and
annotations of node and namespace to trigger pod updates. This leads to
bettwr management of watchers


## How to test this PR locally

See info elastic/beats#37338

## Related issues

- Relates elastic/beats#37338
- Relates elastic/beats#37431

---------

Co-authored-by: Tetiana Kravchenko <[email protected]>
Co-authored-by: Giuseppe Santoro <[email protected]>
@gizas gizas closed this as completed Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

No branches or pull requests

3 participants