Skip to content

remove uses of github.com/runc/libcontainer/cgroups#9045

Merged
AkihiroSuda merged 2 commits intocontainerd:mainfrom
thaJeztah:less_libcontainer
Sep 1, 2023
Merged

remove uses of github.com/runc/libcontainer/cgroups#9045
AkihiroSuda merged 2 commits intocontainerd:mainfrom
thaJeztah:less_libcontainer

Conversation

@thaJeztah
Copy link
Member

remove uses of github.com/runc/libcontainer/cgroups

runc considers libcontainer to be "unstable" (not for external use),
so we try not to use it. Commit ed47d6b (#8722)
brought back the dependency on other parts of libcontainer, but looks to
be only depending on a single utility, which in itself was borrowed from
github.com/coreos/go-systemd to not introduce CGO code in the same package.

This patch copies the version from github.com/coreos/go-systemd (adding
proper attribution, although the function is pretty trivial).

runc is in process of moving the libcontainer/user package to an external
module, which means we can remove the dependency on libcontainer entirely
in the near future. There is one more use of libcontainer in our vendor
tree; it looks like CDI is depending on one utility (devices.DeviceFromPath);

We should remove the dependency on that utility, and add a CI check to
prevent bringing it back.

pkg/systemd: use sync.Once for systemd detection

This brings over the enhancement from moby/moby@a506630 (moby/moby#41656).

We don't expect the systemd state to change while containerd is running,
so we can use a sync.Once for this, to prevent stat'ing each time.

runc considers libcontainer to be "unstable" (not for external use),
so we try not to use it. Commit ed47d6b
brought back the dependency on other parts of libcontainer, but looks to
be only depending on a single utility, which in itself was borrowed from
github.com/coreos/go-systemd to not introduce CGO code in the same package.

This patch copies the version from github.com/coreos/go-systemd (adding
proper attribution, although the function is pretty trivial).

runc is in process of moving the libcontainer/user package to an external
module, which means we can remove the dependency on libcontainer entirely
in the near future. There is one more use of `libcontainer` in our vendor
tree; it looks like CDI is depending on one utility (devices.DeviceFromPath);
https://github.com/containerd/containerd/blob/a943033a8b6d8dd94a171c6e9528ef413b5b22f3/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits_unix.go#L38

We should remove the dependency on that utility, and add a CI check to
prevent bringing it back.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This brings over the enhancement from moby/moby@a506630.

We don't expect the systemd state to change while containerd is running,
so we can use a `sync.Once` for this, to prevent stat'ing each time.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member Author

@@ -0,0 +1,58 @@
//go:build linux
Copy link
Member

Choose a reason for hiding this comment

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

The file name should be _linux.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Heh, I was considering that, but also knew there were some other PR's being reviewed for "no_systemd" build-tags, so thought I could reduce some churn by using build-tags inside the file, but happy to rename if it's a blocker for you ☺️

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.

3 participants