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

[corechecks/containerlifecycle] Add owner info to ContainerEvent #16193

Merged
merged 5 commits into from
Mar 27, 2023

Conversation

sblumenthal
Copy link
Member

What does this PR do?

This PR adds node orchestrator ownership information to the workloadmeta container object, and sends that information up as part of the containerlifecycle container events.

Motivation

We would like to be able to associate containers with the pods which are running them when handling container lifecycle events.

Additional Notes

This is only supported for Kubernetes Pods at the moment, but adding support for other node orchestrators should not require a refactor.

Because the container runtime does not know anything about the node orchestrator which is controlling the container, and because the container events on the container lifecycle side trigger when the container runtime emits the deleted event, we are not able to get the owner information in the event payload that is passed in. As a result of this, I have added a call to pull this information from the global workloadmeta store

Requires DataDog/agent-payload#241

Describe how to test/QA your changes

Like this other PR, testing this is tricky, because (as far as I know) we do not have a way to inspect the payload generated by this check. I was able to validate this locally by building the agent with debug flags set, and then using delve to set breakpoints at the return statements of toPayloadModel and toEventModel in pkg/collector/corechecks/containerlifecycle/event.go. I was able to validate locally that the field is populated this way.

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • A release note has been added or the changelog/no-changelog label has been applied.
  • Changed code has automated tests for its functionality.
  • Adequate QA/testing plan information is provided if the qa/skip-qa label is not applied.
  • At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • If applicable, the need-change/operator and need-change/helm labels have been applied.
  • If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • If applicable, the config template has been updated.

@sblumenthal sblumenthal added this to the 7.45.0 milestone Mar 20, 2023
go.mod Outdated Show resolved Hide resolved
Base automatically changed from sblumenthal/containerlcycle-pod-timestamp to main March 27, 2023 18:42
@sblumenthal sblumenthal force-pushed the sblumenthal/containerlcycle-container-owner-info branch from 78a34f9 to e587a7d Compare March 27, 2023 19:02
@sblumenthal sblumenthal marked this pull request as ready for review March 27, 2023 19:03
@sblumenthal sblumenthal requested review from a team as code owners March 27, 2023 19:03
Copy link
Contributor

@maycmlee maycmlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion

Co-authored-by: May Lee <mayl@alumni.cmu.edu>
@sblumenthal sblumenthal merged commit 29024a0 into main Mar 27, 2023
@sblumenthal sblumenthal deleted the sblumenthal/containerlcycle-container-owner-info branch March 27, 2023 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants