Skip to content

Use slices shared helper instead of duplicating same logic#2898

Closed
tbavelier wants to merge 2 commits into
mainfrom
tbavelier/refactor-apparmor-container-check
Closed

Use slices shared helper instead of duplicating same logic#2898
tbavelier wants to merge 2 commits into
mainfrom
tbavelier/refactor-apparmor-container-check

Conversation

@tbavelier

Copy link
Copy Markdown
Member

What does this PR do?

Title

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

Write there any instructions and details you may have to test your PR.

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed (see: signing commits)

lebauce and others added 2 commits April 13, 2026 16:23
…verrides

The fix in a0dc8c0 added a container existence check to
overrideAppArmorProfile(), preventing invalid AppArmor annotations when
a container (e.g. security-agent with directSendFromSystemProbe=true) is
absent from the pod spec.

However, the same guard was missing from the direct annotation loop in
PodTemplateSpec(), which blindly copies spec.override.nodeAgent.annotations
to the pod template. Any AppArmor annotation set via that path would bypass
the existing fix and still produce an invalid DaemonSet.

Apply the same container existence check when iterating override.Annotations:
skip AppArmor annotations (container.apparmor.security.beta.kubernetes.io/<name>)
if <name> does not match any container in the pod spec.
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 13, 2026

Copy link
Copy Markdown

✅ Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 83.33%
Overall Coverage: 40.14%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 32ccdc6 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov-commenter

codecov-commenter commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 40.05%. Comparing base (0f26877) to head (32ccdc6).

Files with missing lines Patch % Lines
...ontroller/datadogagent/override/podtemplatespec.go 83.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                     @@
##           lebauce/apparmor-fixes-v2    #2898   +/-   ##
==========================================================
  Coverage                      40.04%   40.05%           
==========================================================
  Files                            319      319           
  Lines                          28048    28041    -7     
==========================================================
- Hits                           11233    11232    -1     
+ Misses                         15992    15986    -6     
  Partials                         823      823           
Flag Coverage Δ
unittests 40.05% <85.71%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rnal/controller/datadogagent/override/container.go 95.94% <100.00%> (-0.16%) ⬇️
...ontroller/datadogagent/override/podtemplatespec.go 76.92% <83.33%> (+3.67%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f26877...32ccdc6. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from lebauce/apparmor-fixes-v2 to main April 14, 2026 07:03
@tbavelier

Copy link
Copy Markdown
Member Author

closing, commit was merged as part of #2897

@tbavelier tbavelier closed this Apr 14, 2026
@tbavelier
tbavelier deleted the tbavelier/refactor-apparmor-container-check branch April 14, 2026 07:14
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.

3 participants