Skip to content

pgk/capabilities: modernize, switch to github.com/moby/sys/capability#2167

Merged
openshift-merge-bot[bot] merged 5 commits into
containers:mainfrom
kolyshkin:cap
Sep 26, 2024
Merged

pgk/capabilities: modernize, switch to github.com/moby/sys/capability#2167
openshift-merge-bot[bot] merged 5 commits into
containers:mainfrom
kolyshkin:cap

Conversation

@kolyshkin

@kolyshkin kolyshkin commented Sep 20, 2024

Copy link
Copy Markdown
Contributor

This PR improves pkg/capabilities and switches it to using the new fork. Please see individual commits for details.

github.com/moby/sys/capability is a fork of the (no longer maintained) github.com/syndtr/gocapability package.

For changes since the fork took place, see https://github.com/moby/sys/blob/main/capability/CHANGELOG.md

Related:

@packit-as-a-service

Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

1 similar comment
@packit-as-a-service

Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@Luap99

Luap99 commented Sep 20, 2024

Copy link
Copy Markdown
Member

cross build for darwin is failing

Kernel 2.6.32-573.el6, released 2015-07-22 as part of RHEL 6.7,
supports cap_last_cap file, so there is no need for a workaround.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
sync.OnceValues is available since Go 1.21 and allows to have less
global variables when using sync.Once.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
slices.Sort was introduced in Go 1.21. As the code already imports
slices, using slices.Sort allows to have one less package imported.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Replace init and the two global variables with two functions, capList
and capStrList, wrapped in sync.OnceValues.

This way, there is no runtime overhead of merely including this package,
as these functions are executed as needed, not during program
initialization.

While at it:
 - rename getCapName to capName for brewity;
 - use slices.DeleteFunc in capList to filter the slice in place instead
   of making a copy (less garbage to collect);
 - improve AllCapabilities documentation.

Note that currently neither function returns an error; this is a
preparation for the next patch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This is a fork of the (no longer maintained)
github.com/syndtr/gocapability package.

For changes since the fork took place, see
https://github.com/moby/sys/blob/main/capability/CHANGELOG.md

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

@Luap99 Luap99 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, would be great if we could get a new runtime-tools version with the change there in as well before the next podman release so we do not have to ship two capability packages due avoid unnecessary bloat.

@openshift-ci

openshift-ci Bot commented Sep 26, 2024

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kolyshkin, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan

rhatdan commented Sep 26, 2024

Copy link
Copy Markdown
Member

/lgtm

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.

3 participants