Skip to content

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

Merged
mikebrow merged 1 commit into
containerd:mainfrom
thc1006:fix-adjustsysctl-removal-map
Aug 20, 2026
Merged

mikebrow merged 1 commit into
containerd:mainfrom
thc1006:fix-adjustsysctl-removal-map

Conversation

@thc1006

@thc1006 thc1006 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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 <[email protected]>
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.

@klihub

klihub commented Aug 19, 2026

Copy link
Copy Markdown
Member

@thc1006 Thanks for the fix. This LGTM.

I think it probably would be good to add a RemoveLinuxSysctl for completeness, if such an operation makes sense at all. Otherwise there is no reason to handle removals, although folks could misuse SetLinuxSysctl to trigger it, but then that's something we'd rather have a dedicated function for.

@klihub
klihub self-requested a review August 19, 2026 15:46
@klihub
klihub requested review from mikebrow and samuelkarp August 20, 2026 07:47
@mikebrow
mikebrow requested a lite review from Copilot August 20, 2026 14:21

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM thanks for the catch and fix

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

pkg/adaptation/result.go:508

  • There’s currently no test coverage for the pure sysctl removal-marker path (i.e., only a MarkForRemoval(k) entry with no corresponding set). Given this was a subtle bug (markers ended up in Annotations), adding a focused regression test would help prevent recurrence (either a unit test calling adjustSysctl directly or a plugin-facing helper that can express removals).
	for k := range del {
		r.reply.adjust.Linux.Sysctl[MarkForRemoval(k)] = ""
	}

@mikebrow
mikebrow merged commit 479cb6d into containerd:main Aug 20, 2026
16 checks passed
@thc1006
thc1006 deleted the fix-adjustsysctl-removal-map branch August 20, 2026 14:47
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.

4 participants