Skip to content

ci: bump golangci-lint to v2.10, fix some prealloc linter warnings#5118

Merged
lifubang merged 2 commits into
opencontainers:mainfrom
kolyshkin:lint29
Feb 27, 2026
Merged

ci: bump golangci-lint to v2.10, fix some prealloc linter warnings#5118
lifubang merged 2 commits into
opencontainers:mainfrom
kolyshkin:lint29

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin commented Feb 11, 2026

  • ci: bump golangci-lint to v2.10

  • Preallocate some slices

    These were found by the prealloc linter. While it does not make sense
    to address all of prealloc warnings (or add it to the list of linters
    we run in CI), some do make sense.

Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

You mention you skip this in runc features, but it doesn't seem to be here. Wasn't it needed in the end and the commit is outdated?

Comment thread libcontainer/specconv/spec_linux.go
Comment thread libcontainer/specconv/spec_linux.go
Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

The more I look at this, the more unsure I am this is worth it. Linters should help us not review "trivial things" (like spaces, capitalization of variables, etc.) and make the code better.

If it ends up adding lot of "ignore this" everywhere, it is just too painful and we can remove it later. But I'm not convinced the value it adds. Also, our slices are not that big, I don't think it either has a big performance implication nor that the compiler in the future couldn't be smarter (our allocations are quite simple, most part of the same function).

Do you find yourself requesting this change on PRs? If so, then it is worth to have a linter.

If you like it, let's do add it :)

@kolyshkin kolyshkin changed the title ci: bump golangci-lint to v2.9, add prealloc linter ci: bump golangci-lint to v2.9, fix some prealloc linter warnings Feb 13, 2026
@kolyshkin kolyshkin changed the title ci: bump golangci-lint to v2.9, fix some prealloc linter warnings ci: bump golangci-lint to v2.10, fix some prealloc linter warnings Feb 23, 2026
@kolyshkin kolyshkin requested a review from rata February 23, 2026 20:00
Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

The CI failures are new to me:

# chcon: failed to change context of '/tmp/bats-run-3MMyYP/runc.szTqBc/bundle/runc' to ‘system_u:object_r:container_runtime_exec_t:s0’: Invalid argument

They don't seem related at all, though :)

@kolyshkin
Copy link
Copy Markdown
Contributor Author

kolyshkin commented Feb 24, 2026

chcon: failed to change context of '/tmp/bats-run-3MMyYP/runc.szTqBc/bundle/runc' to ‘system_u:object_r:container_runtime_exec_t:s0’: Invalid argument

Looks like this is caused by a broken install of containers-selinux rpm:

  Running scriptlet: container-selinux-4:2.246.0-1.el10.noarch            26/37 
  Installing       : container-selinux-4:2.246.0-1.el10.noarch            26/37 
  Running scriptlet: container-selinux-4:2.246.0-1.el10.noarch            26/37 
libsemanage.semanage_pipe_data: Child process /usr/libexec/selinux/hll/pp failed with code: 255. (No data available).
libsemanage.semanage_compile_module: container: libsepol.policydb_read: policydb module version 24 does not match my version range 4-23.
libsemanage.semanage_compile_module: container: libsepol.sepol_module_package_read: invalid module in module package (at section 0).
libsemanage.semanage_compile_module: container: libsepol.sepol_ppfile_to_module_package: Failed to read policy package.
libsemanage.semanage_direct_commit: Failed to compile hll files into cil files. (No data available).
semodule:  Failed!

Restarted the job to see if it's something temporary.

@kolyshkin
Copy link
Copy Markdown
Contributor Author

Restarted the job to see if it's something temporary.

It is not. Addressed by #5123.

Fix *some* of the prealloc linter warnings. While it does not make sense
to address all warnings (or add prealloc to the list of linters we run
in CI), some do make sense.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Copy Markdown
Contributor Author

Rebased to fix CI

Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM

@kolyshkin
Copy link
Copy Markdown
Contributor Author

@lifubang @thaJeztah PTAL

@lifubang lifubang merged commit 8de198f into opencontainers:main Feb 27, 2026
42 checks passed
@rata
Copy link
Copy Markdown
Member

rata commented Mar 2, 2026

@kolyshkin this golang blog article about optimizing allocations was just published. The compiler is now much more effective: https://go.dev/blog/allocation-optimizations

It's not that it doesn't make sense to do the length anymore, but it's way way better.

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