Skip to content

never let PodTemplateSpec rewrite Host Profiler seccomp init container#3135

Open
theomagellan wants to merge 2 commits into
mainfrom
theomagellan/init-container-image
Open

never let PodTemplateSpec rewrite Host Profiler seccomp init container#3135
theomagellan wants to merge 2 commits into
mainfrom
theomagellan/init-container-image

Conversation

@theomagellan

@theomagellan theomagellan commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Fixes host-profiler-seccomp-setup init container using the wrong image. override.PodTemplateSpec rewrites all init container images to spec.override.nodeAgent.image, but host-profiler-seccomp-setup must use the profiler image to copy its seccomp profile, which the agent image doesn't have.
    The fix skips host-profiler-seccomp-setup in the init container rewrite loop.

  • Reverts the workaround introduced in [Host Profiler] Remove seccomp configmap and use profile baked into image #3061 (resolveHostProfilerImage reading spec.override.nodeAgent.image), which was trying to keep the hash and init container image consistent with each other around the wrong image.

Motivation

host-profiler-seccomp-setup was failing on nightly because it was running from the agent image and trying to copy a file that doesn't exist there.

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

On test cluster using main:

  1. set spec.override.nodeAgent.image
  2. observed the init container with the wrong image

Repeated these steps with fix included to confirm.

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)

@datadog-prod-us1-3

This comment has been minimized.

@theomagellan theomagellan force-pushed the theomagellan/init-container-image branch from ecd1dfa to aed9541 Compare June 12, 2026 16:04
@theomagellan theomagellan added qa/skip-qa bug Something isn't working labels Jun 12, 2026
@theomagellan theomagellan changed the title never let podtemplate rewrite host profiler seccomp init container never let PodTemplateSpec rewrite Host Profiler seccomp init container Jun 12, 2026
@theomagellan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aed954126e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +88 to +89
if apicommon.AgentContainerName(initContainer.Name) == apicommon.HostProfilerSeccompSetupContainerName {
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply pull policy to the profiler seccomp init

When spec.override.nodeAgent.image.pullPolicy is set, this continue skips both the image rewrite and the pull-policy assignment below, so host-profiler-seccomp-setup keeps its default pull policy while the host-profiler container is updated. In clusters that reuse a mutable profiler tag and set Always/Never via the override, the init container can copy a stale or disallowed seccomp JSON before the main profiler image is pulled with the requested policy. The skip should avoid only changing the image, while still honoring override.Image.PullPolicy for this init container.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Host Profiler is only supported through annotations with the image-override-config. spec.override.nodeAgent.image.pullPolicy doesn't apply to the annotation.

@codecov-commenter

codecov-commenter commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.59%. Comparing base (ef74881) to head (cd85d77).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3135      +/-   ##
==========================================
- Coverage   43.59%   43.59%   -0.01%     
==========================================
  Files         354      354              
  Lines       30224    30220       -4     
==========================================
- Hits        13177    13174       -3     
+ Misses      16176    16175       -1     
  Partials      871      871              
Flag Coverage Δ
unittests 43.59% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...oller/datadogagent/feature/hostprofiler/feature.go 82.00% <100.00%> (-0.08%) ⬇️
...oller/datadogagent/feature/hostprofiler/seccomp.go 100.00% <100.00%> (ø)
...ontroller/datadogagent/override/podtemplatespec.go 80.37% <100.00%> (+0.25%) ⬆️

Continue to review full report in Codecov by Harness.

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

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

@theomagellan theomagellan marked this pull request as ready for review June 12, 2026 16:38
@theomagellan theomagellan requested a review from a team June 12, 2026 16:38
@theomagellan theomagellan requested a review from a team as a code owner June 12, 2026 16:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aed954126e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +88 to +89
if apicommon.AgentContainerName(initContainer.Name) == apicommon.HostProfilerSeccompSetupContainerName {
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the profiler seccomp image aligned with nodeAgent overrides

When Host Profiler is enabled and spec.override.nodeAgent.image points at a full replacement image, the regular container loop still rewrites the host-profiler container via OverrideAgentImage (line 77), but this new continue leaves host-profiler-seccomp-setup on the pre-override image and ManageNodeAgent has already hashed that pre-override image for LocalhostProfile. The pod then runs the profiler from the overridden image while copying/registering a seccomp profile from a different image/version, which can fail if the profile path or syscalls differ. This is not the earlier pull-policy comment; the fresh evidence is that the same patch's test expects the host-profiler container image to be overridden while this init container is not.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

spec.override.nodeAgent.image doesn't point at a full replacement image since the Host Profiler is not yet bundled in the agent image; the Host Profiler IS ONLY enabled by using its override annotation which has a higher precedence than spec.override.nodeAgent.image.
If the annotation wasn't set, we would be using the profiler's default image, which is the agent's image so it should also be correct for when the profiler is bundled in the agent's image.
This would need to be checked again when time comes, Codex is hard to follow here so I did my best to cover our bases.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@theomagellan I wonder if this implies that host-profiler image override should be skipped similar to host profiler init container. This will resolve image based on the annotation but if host-profiler image override is present resolved image name will be wrong.

// host-profiler-seccomp-setup copies a seccomp profile JSON baked into the profiler image, not the agent image
// until the profiler is bundled in the agent.
if apicommon.AgentContainerName(initContainer.Name) == apicommon.HostProfilerSeccompSetupContainerName {
continue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

fyi, global settings may modify image registry and suffix

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