Skip to content

fix(adaptation): record sysctl removal markers in Linux.Sysctl#300

Open
thc1006 wants to merge 1 commit into
containerd:mainfrom
thc1006:fix-adjustsysctl-removal-map
Open

fix(adaptation): record sysctl removal markers in Linux.Sysctl#300
thc1006 wants to merge 1 commit into
containerd:mainfrom
thc1006:fix-adjustsysctl-removal-map

Conversation

@thc1006

@thc1006 thc1006 commented Jul 10, 2026

Copy link
Copy Markdown

What this PR does

adjustSysctl records sysctl removal markers in the wrong map. In its final loop over pure removals it writes to Annotations:

for k := range del {
    r.reply.adjust.Annotations[MarkForRemoval(k)] = ""
}

The set-and-remove branch earlier in the same function already writes the correct map (r.reply.adjust.Linux.Sysctl[MarkForRemoval(k)] = ""), and adjustAnnotations is the function that legitimately writes Annotations. As written, a plugin's pure sysctl removal is not propagated to the container spec (generate.AdjustSysctl never sees the marker) and a spurious annotation-removal marker is emitted instead. This changes the final loop to write Linux.Sysctl.

On testing

I did not add a dedicated test here. Unlike annotations and mounts, sysctl removal is not exposed through a plugin-facing adjustment method (there is SetLinuxSysctl but no RemoveLinuxSysctl), so the removal-collection path is not exercised by the existing plugin-facing suite in adaptation_suite_test.go. The existing suite still passes (go test ./pkg/adaptation/). I am happy to follow up with a RemoveLinuxSysctl helper plus a removal test, or a focused test against adjustSysctl, whichever you prefer.

Notes

Verified with go build, go vet, gofmt, and the existing ./pkg/adaptation/ tests.

adjustSysctl recorded sysctl removal markers in the Annotations map
instead of Linux.Sysctl in its final (pure-removal) loop, so a plugin's
sysctl removal was not propagated to the container spec and a spurious
annotation-removal marker was produced. Write the marker to Linux.Sysctl,
matching the set-and-remove branch earlier in the same function.

Signed-off-by: Hsiu-Chi Tsai <84045975+thc1006@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 10, 2026 03:42

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants