summaryrefslogtreecommitdiff
path: root/vendor/github.com/containerd/cgroups/cgroup.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-13 20:23:21 +0200
committerGitHub <noreply@github.com>2019-05-13 20:23:21 +0200
commit25415e0b0edb0f120cedcc10b9aed7f15cd9e086 (patch)
tree72719f434fabfb1cf7b76772df6a7371f4b39f9d /vendor/github.com/containerd/cgroups/cgroup.go
parente0f123056581e399b6c0d0282462164d8b8957c5 (diff)
parent60d43effb017e0e0f6475b48ea8efe3e8ad0448a (diff)
downloadpodman-25415e0b0edb0f120cedcc10b9aed7f15cd9e086.tar.gz
podman-25415e0b0edb0f120cedcc10b9aed7f15cd9e086.tar.bz2
podman-25415e0b0edb0f120cedcc10b9aed7f15cd9e086.zip
Merge pull request #3103 from mheon/update_cgroups
Update containerd/cgroups to 4994991857f9b0ae
Diffstat (limited to 'vendor/github.com/containerd/cgroups/cgroup.go')
-rw-r--r--vendor/github.com/containerd/cgroups/cgroup.go45
1 files changed, 42 insertions, 3 deletions
diff --git a/vendor/github.com/containerd/cgroups/cgroup.go b/vendor/github.com/containerd/cgroups/cgroup.go
index 03fcb9284..e3ef07651 100644
--- a/vendor/github.com/containerd/cgroups/cgroup.go
+++ b/vendor/github.com/containerd/cgroups/cgroup.go
@@ -30,24 +30,49 @@ import (
)
// New returns a new control via the cgroup cgroups interface
-func New(hierarchy Hierarchy, path Path, resources *specs.LinuxResources) (Cgroup, error) {
+func New(hierarchy Hierarchy, path Path, resources *specs.LinuxResources, opts ...InitOpts) (Cgroup, error) {
+ config := newInitConfig()
+ for _, o := range opts {
+ if err := o(config); err != nil {
+ return nil, err
+ }
+ }
subsystems, err := hierarchy()
if err != nil {
return nil, err
}
+ var active []Subsystem
for _, s := range subsystems {
+ // check if subsystem exists
if err := initializeSubsystem(s, path, resources); err != nil {
+ if err == ErrControllerNotActive {
+ if config.InitCheck != nil {
+ if skerr := config.InitCheck(s, path, err); skerr != nil {
+ if skerr != ErrIgnoreSubsystem {
+ return nil, skerr
+ }
+ }
+ }
+ continue
+ }
return nil, err
}
+ active = append(active, s)
}
return &cgroup{
path: path,
- subsystems: subsystems,
+ subsystems: active,
}, nil
}
// Load will load an existing cgroup and allow it to be controlled
-func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
+func Load(hierarchy Hierarchy, path Path, opts ...InitOpts) (Cgroup, error) {
+ config := newInitConfig()
+ for _, o := range opts {
+ if err := o(config); err != nil {
+ return nil, err
+ }
+ }
var activeSubsystems []Subsystem
subsystems, err := hierarchy()
if err != nil {
@@ -60,6 +85,16 @@ func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
if os.IsNotExist(errors.Cause(err)) {
return nil, ErrCgroupDeleted
}
+ if err == ErrControllerNotActive {
+ if config.InitCheck != nil {
+ if skerr := config.InitCheck(s, path, err); skerr != nil {
+ if skerr != ErrIgnoreSubsystem {
+ return nil, skerr
+ }
+ }
+ }
+ continue
+ }
return nil, err
}
if _, err := os.Lstat(s.Path(p)); err != nil {
@@ -70,6 +105,10 @@ func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
}
activeSubsystems = append(activeSubsystems, s)
}
+ // if we do not have any active systems then the cgroup is deleted
+ if len(activeSubsystems) == 0 {
+ return nil, ErrCgroupDeleted
+ }
return &cgroup{
path: path,
subsystems: activeSubsystems,