Skip to content

Commit 28b65d3

Browse files
authored
Merge pull request opencontainers#4472 from kolyshkin/cg-cfg
libct/configs: move cgroup configs to libct/cgroups
2 parents 2e1559e + 5a838cc commit 28b65d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+323
-338
lines changed

libcontainer/cgroups/cgroups.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package cgroups
22

33
import (
44
"errors"
5-
6-
"github.com/opencontainers/runc/libcontainer/configs"
75
)
86

97
var (
@@ -21,8 +19,8 @@ var (
2119
// [github.com/opencontainers/runc/libcontainer/cgroups/devices]
2220
// package is imported, it is set to nil, so cgroup managers can't
2321
// manage devices.
24-
DevicesSetV1 func(path string, r *configs.Resources) error
25-
DevicesSetV2 func(path string, r *configs.Resources) error
22+
DevicesSetV1 func(path string, r *Resources) error
23+
DevicesSetV2 func(path string, r *Resources) error
2624
)
2725

2826
type Manager interface {
@@ -42,7 +40,7 @@ type Manager interface {
4240
GetStats() (*Stats, error)
4341

4442
// Freeze sets the freezer cgroup to the specified state.
45-
Freeze(state configs.FreezerState) error
43+
Freeze(state FreezerState) error
4644

4745
// Destroy removes cgroup.
4846
Destroy() error
@@ -54,7 +52,7 @@ type Manager interface {
5452
// Set sets cgroup resources parameters/limits. If the argument is nil,
5553
// the resources specified during Manager creation (or the previous call
5654
// to Set) are used.
57-
Set(r *configs.Resources) error
55+
Set(r *Resources) error
5856

5957
// GetPaths returns cgroup path(s) to save in a state file in order to
6058
// restore later.
@@ -67,10 +65,10 @@ type Manager interface {
6765
GetPaths() map[string]string
6866

6967
// GetCgroups returns the cgroup data as configured.
70-
GetCgroups() (*configs.Cgroup, error)
68+
GetCgroups() (*Cgroup, error)
7169

7270
// GetFreezerState retrieves the current FreezerState of the cgroup.
73-
GetFreezerState() (configs.FreezerState, error)
71+
GetFreezerState() (FreezerState, error)
7472

7573
// Exists returns whether the cgroup path exists or not.
7674
Exists() bool

libcontainer/configs/blkio_device.go renamed to libcontainer/cgroups/config_blkio_device.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
import "fmt"
44

libcontainer/configs/hugepage_limit.go renamed to libcontainer/cgroups/config_hugepages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
type HugepageLimit struct {
44
// which type of hugepage to limit.

libcontainer/configs/interface_priority_map.go renamed to libcontainer/cgroups/config_ifprio_map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
import (
44
"fmt"

libcontainer/configs/cgroup_linux.go renamed to libcontainer/cgroups/config_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
import (
44
systemdDbus "github.com/coreos/go-systemd/v22/dbus"

libcontainer/configs/rdma.go renamed to libcontainer/cgroups/config_rdma.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package configs
1+
package cgroups
22

33
// LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11)
44
type LinuxRdma struct {

libcontainer/configs/cgroup_unsupported.go renamed to libcontainer/cgroups/config_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build !linux
22

3-
package configs
3+
package cgroups
44

55
// Cgroup holds properties of a cgroup on Linux
66
// TODO Windows: This can ultimately be entirely factored out on Windows as

libcontainer/cgroups/devices/systemd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"github.com/godbus/dbus/v5"
1212
"github.com/sirupsen/logrus"
1313

14-
"github.com/opencontainers/runc/libcontainer/configs"
14+
"github.com/opencontainers/runc/libcontainer/cgroups"
1515
"github.com/opencontainers/runc/libcontainer/devices"
1616
)
1717

1818
// systemdProperties takes the configured device rules and generates a
1919
// corresponding set of systemd properties to configure the devices correctly.
20-
func systemdProperties(r *configs.Resources, sdVer int) ([]systemdDbus.Property, error) {
20+
func systemdProperties(r *cgroups.Resources, sdVer int) ([]systemdDbus.Property, error) {
2121
if r.SkipDevices {
2222
return nil, nil
2323
}

libcontainer/cgroups/devices/systemd_test.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/opencontainers/runc/libcontainer/cgroups"
1212
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
13-
"github.com/opencontainers/runc/libcontainer/configs"
1413
"github.com/opencontainers/runc/libcontainer/devices"
1514
)
1615

@@ -28,11 +27,11 @@ func TestPodSkipDevicesUpdate(t *testing.T) {
2827
}
2928

3029
podName := "system-runc_test_pod" + t.Name() + ".slice"
31-
podConfig := &configs.Cgroup{
30+
podConfig := &cgroups.Cgroup{
3231
Systemd: true,
3332
Parent: "system.slice",
3433
Name: podName,
35-
Resources: &configs.Resources{
34+
Resources: &cgroups.Resources{
3635
PidsLimit: 42,
3736
Memory: 32 * 1024 * 1024,
3837
SkipDevices: true,
@@ -47,11 +46,11 @@ func TestPodSkipDevicesUpdate(t *testing.T) {
4746
t.Fatal(err)
4847
}
4948

50-
containerConfig := &configs.Cgroup{
49+
containerConfig := &cgroups.Cgroup{
5150
Parent: podName,
5251
ScopePrefix: "test",
5352
Name: "PodSkipDevicesUpdate",
54-
Resources: &configs.Resources{
53+
Resources: &cgroups.Resources{
5554
Devices: []*devices.Rule{
5655
// Allow access to /dev/null.
5756
{
@@ -124,10 +123,10 @@ func testSkipDevices(t *testing.T, skipDevices bool, expected []string) {
124123
t.Skip("Test requires root.")
125124
}
126125

127-
podConfig := &configs.Cgroup{
126+
podConfig := &cgroups.Cgroup{
128127
Parent: "system.slice",
129128
Name: "system-runc_test_pods.slice",
130-
Resources: &configs.Resources{
129+
Resources: &cgroups.Resources{
131130
SkipDevices: skipDevices,
132131
},
133132
}
@@ -140,11 +139,11 @@ func testSkipDevices(t *testing.T, skipDevices bool, expected []string) {
140139
t.Fatal(err)
141140
}
142141

143-
config := &configs.Cgroup{
142+
config := &cgroups.Cgroup{
144143
Parent: "system-runc_test_pods.slice",
145144
ScopePrefix: "test",
146145
Name: "SkipDevices",
147-
Resources: &configs.Resources{
146+
Resources: &cgroups.Resources{
148147
Devices: []*devices.Rule{
149148
// Allow access to /dev/full only.
150149
{
@@ -262,7 +261,7 @@ func BenchmarkFindDeviceGroup(b *testing.B) {
262261
}
263262
}
264263

265-
func newManager(t *testing.T, config *configs.Cgroup) (m cgroups.Manager) {
264+
func newManager(t *testing.T, config *cgroups.Cgroup) (m cgroups.Manager) {
266265
t.Helper()
267266
var err error
268267

libcontainer/cgroups/devices/v1.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77

88
"github.com/moby/sys/userns"
99
"github.com/opencontainers/runc/libcontainer/cgroups"
10-
"github.com/opencontainers/runc/libcontainer/configs"
1110
"github.com/opencontainers/runc/libcontainer/devices"
1211
)
1312

1413
var testingSkipFinalCheck bool
1514

16-
func setV1(path string, r *configs.Resources) error {
15+
func setV1(path string, r *cgroups.Resources) error {
1716
if userns.RunningInUserNS() || r.SkipDevices {
1817
return nil
1918
}

0 commit comments

Comments
 (0)