Skip to content

pkg/kernelversion: fix linting and sync with upstream - #13701

Merged
fuweid merged 4 commits into
containerd:mainfrom
thaJeztah:kernel_ver_cleans
Jul 3, 2026
Merged

fuweid merged 4 commits into
containerd:mainfrom
thaJeztah:kernel_ver_cleans

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

pkg/kernelversion: use unix.ByteSliceToString for utsname fields

similar to moby@8a5c131

pkg/kernelversion: fix minor linting issues

pkg/kernelversion: simplify code with sync.OnceValues

pkg/kernelversion: update links to upstream source

The package was moved to a separate module; update the links to
make it easier to discover the current version of upstream.

Copilot AI review requested due to automatic review settings July 1, 2026 09:04
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates pkg/kernelversion to align with upstream seccomp profile sources and modern Go idioms while cleaning up minor linting issues.

Changes:

  • Switch kernel release string conversion to unix.ByteSliceToString for NUL-terminated utsname fields.
  • Simplify kernel version caching logic using sync.OnceValues and ensure uname failures propagate as errors.
  • Update upstream reference links and adjust tests to use errors.New where formatting isn’t needed.

Reviewed changes

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

File Description
pkg/kernelversion/kernel_linux.go Uses unix.ByteSliceToString and sync.OnceValues to simplify and harden kernel version detection/caching; updates upstream link.
pkg/kernelversion/kernel_linux_test.go Removes unnecessary fmt usage, keeps error expectations stable via message comparisons; updates upstream link.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thaJeztah
thaJeztah force-pushed the kernel_ver_cleans branch from 5056924 to 4eae619 Compare July 1, 2026 09:42
Comment thread pkg/kernelversion/kernel_linux.go Outdated
/*
File copied and customized based on
https://github.com/moby/moby/tree/v20.10.14/profiles/seccomp/kernel_linux.go
https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/kernel_linux.go

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.

If we're in here anyway, it'd be good to include the copyright information of that file as well. Both are Apache 2.0 and compatible, but right now we're just crediting "The containerd Authors." but we should also credit "The Moby Authors." (and yes, a lot of those are the same people 😂).

Suggested change
https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/kernel_linux.go
https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/kernel_linux.go
Copyright The Moby Authors.
SPDX-License-Identifier: Apache-2.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Heh; yes, while working on this PR, I actually noticed that the "correct" header is SPDX-FileCopyrightText nowadays; moby/profiles#34

And when forking (like in this repository) it could even be SPDX-SnippetCopyrightText:; https://spdx.github.io/spdx-spec/v2.3/file-tags/#h3-snippet-tags-format

(and yes, a lot of those are the same people 😂).

Yup! Lot of code in the container ecosystem moved around multiple times. I think it's the right thing to do (at least best effort to give credits due where credits due), but it can add a lot of noise / boilerplating.

To reduce noise, I've actually contemplated to switch to SPDX headers in containerd as well (I can open a ticket / draft PR for that)

Copilot AI review requested due to automatic review settings July 2, 2026 10:53
@thaJeztah
thaJeztah force-pushed the kernel_ver_cleans branch from 4eae619 to b179c1f Compare July 2, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread pkg/kernelversion/kernel_linux.go Resolved
Comment on lines +17 to +18
// SPDX-FileCopyrightText: Copyright The Moby Authors
// SPDX-License-Identifier: Apache-2.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm.. right yeah, if that otherwise means it "discards" the top-level apache header, we probably need to repeat.

One more reason to consider using SPDX for containerd itself as well

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated no new comments.

@thaJeztah

Copy link
Copy Markdown
Member Author

The Vagrant things look pretty unstable recently; is it rate limits?

Screenshot 2026-07-02 at 13 38 21

thaJeztah added 4 commits July 2, 2026 17:11
similar to [moby@8a5c131]

[moby@8a5c131]: moby/moby@8a5c131

Signed-off-by: Sebastiaan van Stijn <[email protected]>
The package was moved to a separate module; update the links to
make it easier to discover the current version of upstream.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
thaJeztah force-pushed the kernel_ver_cleans branch from 0b302ea to 296f917 Compare July 2, 2026 15:11
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Jul 2, 2026
@fuweid
fuweid added this pull request to the merge queue Jul 3, 2026
Merged via the queue into containerd:main with commit 9912b96 Jul 3, 2026
50 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jul 3, 2026
@thaJeztah
thaJeztah deleted the kernel_ver_cleans branch July 6, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants