Merge pull request #12498 from rhatdan/cgroups

Update vendor or containers/common moving pkg/cgroups there
This commit is contained in:
OpenShift Merge Robot 2021-12-07 12:49:57 +00:00 committed by GitHub
commit 23ce826a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 41 additions and 70 deletions

View File

@ -8,11 +8,11 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/api/handlers" "github.com/containers/podman/v3/pkg/api/handlers"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgen"

View File

@ -4,10 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/utils" "github.com/containers/podman/v3/cmd/podman/utils"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -4,10 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/utils" "github.com/containers/podman/v3/cmd/podman/utils"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -17,10 +17,10 @@ import (
"github.com/containers/buildah/copier" "github.com/containers/buildah/copier"
"github.com/containers/buildah/pkg/overlay" "github.com/containers/buildah/pkg/overlay"
butil "github.com/containers/buildah/util" butil "github.com/containers/buildah/util"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/chown" "github.com/containers/common/pkg/chown"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/ctime" "github.com/containers/podman/v3/pkg/ctime"
"github.com/containers/podman/v3/pkg/hooks" "github.com/containers/podman/v3/pkg/hooks"
"github.com/containers/podman/v3/pkg/hooks/exec" "github.com/containers/podman/v3/pkg/hooks/exec"

View File

@ -28,6 +28,7 @@ import (
"github.com/containers/buildah/pkg/overlay" "github.com/containers/buildah/pkg/overlay"
butil "github.com/containers/buildah/util" butil "github.com/containers/buildah/util"
"github.com/containers/common/pkg/apparmor" "github.com/containers/common/pkg/apparmor"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/chown" "github.com/containers/common/pkg/chown"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/subscriptions" "github.com/containers/common/pkg/subscriptions"
@ -36,7 +37,6 @@ import (
"github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/annotations" "github.com/containers/podman/v3/pkg/annotations"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/checkpoint/crutils" "github.com/containers/podman/v3/pkg/checkpoint/crutils"
"github.com/containers/podman/v3/pkg/criu" "github.com/containers/podman/v3/pkg/criu"
"github.com/containers/podman/v3/pkg/lookup" "github.com/containers/podman/v3/pkg/lookup"

View File

@ -14,11 +14,11 @@ import (
"github.com/containers/buildah" "github.com/containers/buildah"
"github.com/containers/common/pkg/apparmor" "github.com/containers/common/pkg/apparmor"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/seccomp" "github.com/containers/common/pkg/seccomp"
"github.com/containers/image/v5/pkg/sysregistriesv2" "github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/linkmode" "github.com/containers/podman/v3/libpod/linkmode"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/storage" "github.com/containers/storage"
"github.com/containers/storage/pkg/system" "github.com/containers/storage/pkg/system"

View File

@ -22,11 +22,11 @@ import (
"text/template" "text/template"
"time" "time"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
conmonConfig "github.com/containers/conmon/runner/config" conmonConfig "github.com/containers/conmon/runner/config"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/logs" "github.com/containers/podman/v3/libpod/logs"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/checkpoint/crutils" "github.com/containers/podman/v3/pkg/checkpoint/crutils"
"github.com/containers/podman/v3/pkg/errorhandling" "github.com/containers/podman/v3/pkg/errorhandling"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"

View File

@ -3,9 +3,9 @@ package libpod
import ( import (
"context" "context"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/parallel" "github.com/containers/podman/v3/pkg/parallel"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -19,6 +19,7 @@ import (
"github.com/containers/buildah/pkg/parse" "github.com/containers/buildah/pkg/parse"
"github.com/containers/common/libimage" "github.com/containers/common/libimage"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/secrets" "github.com/containers/common/pkg/secrets"
"github.com/containers/image/v5/pkg/sysregistriesv2" "github.com/containers/image/v5/pkg/sysregistriesv2"
@ -32,7 +33,6 @@ import (
nettypes "github.com/containers/podman/v3/libpod/network/types" nettypes "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/libpod/plugin" "github.com/containers/podman/v3/libpod/plugin"
"github.com/containers/podman/v3/libpod/shutdown" "github.com/containers/podman/v3/libpod/shutdown"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/systemd" "github.com/containers/podman/v3/pkg/systemd"
"github.com/containers/podman/v3/pkg/util" "github.com/containers/podman/v3/pkg/util"

View File

@ -9,11 +9,11 @@ import (
"time" "time"
"github.com/containers/buildah" "github.com/containers/buildah"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/libpod/shutdown" "github.com/containers/podman/v3/libpod/shutdown"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities/reports" "github.com/containers/podman/v3/pkg/domain/entities/reports"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgen"

View File

@ -9,10 +9,10 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgen"
spec "github.com/opencontainers/runtime-spec/specs-go" spec "github.com/opencontainers/runtime-spec/specs-go"

View File

@ -8,8 +8,8 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -7,8 +7,8 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/opencontainers/selinux/go-selinux/label" "github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -5,11 +5,11 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/api/handlers/utils" "github.com/containers/podman/v3/pkg/api/handlers/utils"
api "github.com/containers/podman/v3/pkg/api/types" api "github.com/containers/podman/v3/pkg/api/types"
"github.com/containers/podman/v3/pkg/cgroups"
docker "github.com/docker/docker/api/types" docker "github.com/docker/docker/api/types"
"github.com/gorilla/schema" "github.com/gorilla/schema"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -4,10 +4,10 @@ import (
"encoding/json" "encoding/json"
"net/http" "net/http"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/api/handlers/utils" "github.com/containers/podman/v3/pkg/api/handlers/utils"
api "github.com/containers/podman/v3/pkg/api/types" api "github.com/containers/podman/v3/pkg/api/types"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/domain/infra/abi" "github.com/containers/podman/v3/pkg/domain/infra/abi"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"

View File

@ -1,32 +0,0 @@
package cgroups
import (
"testing"
"github.com/containers/podman/v3/pkg/rootless"
spec "github.com/opencontainers/runtime-spec/specs-go"
)
func TestCreated(t *testing.T) {
// tests only works in rootless mode
if rootless.IsRootless() {
return
}
var resources spec.LinuxResources
cgr, err := New("machine.slice", &resources)
if err != nil {
t.Error(err)
}
if err := cgr.Delete(); err != nil {
t.Error(err)
}
cgr, err = NewSystemd("machine.slice")
if err != nil {
t.Error(err)
}
if err := cgr.Delete(); err != nil {
t.Error(err)
}
}

View File

@ -10,13 +10,13 @@ import (
"time" "time"
"github.com/containers/buildah" "github.com/containers/buildah"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/image/v5/manifest" "github.com/containers/image/v5/manifest"
"github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/libpod/logs" "github.com/containers/podman/v3/libpod/logs"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/checkpoint" "github.com/containers/podman/v3/pkg/checkpoint"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/domain/entities/reports" "github.com/containers/podman/v3/pkg/domain/entities/reports"

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/utils" "github.com/containers/podman/v3/utils"

View File

@ -8,9 +8,9 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/domain/entities/reports" "github.com/containers/podman/v3/pkg/domain/entities/reports"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"

View File

@ -9,9 +9,9 @@ import (
"os/signal" "os/signal"
"sync" "sync"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/cmd/podman/utils" "github.com/containers/podman/v3/cmd/podman/utils"
"github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/namespaces" "github.com/containers/podman/v3/pkg/namespaces"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"

View File

@ -6,10 +6,10 @@ import (
"strings" "strings"
"github.com/containers/common/libimage" "github.com/containers/common/libimage"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgen"
spec "github.com/opencontainers/runtime-spec/specs-go" spec "github.com/opencontainers/runtime-spec/specs-go"

View File

@ -4,8 +4,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/sysinfo" "github.com/containers/common/pkg/sysinfo"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/specgen"
"github.com/containers/podman/v3/utils" "github.com/containers/podman/v3/utils"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -5,7 +5,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/containers/podman/v3/pkg/cgroups" "github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/podman/v3/pkg/util" "github.com/containers/podman/v3/pkg/util"
"github.com/containers/storage" "github.com/containers/storage"

View File

@ -15,8 +15,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/inspect" "github.com/containers/podman/v3/pkg/inspect"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
. "github.com/containers/podman/v3/test/utils" . "github.com/containers/podman/v3/test/utils"

View File

@ -12,7 +12,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/containers/podman/v3/pkg/cgroups" "github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
. "github.com/containers/podman/v3/test/utils" . "github.com/containers/podman/v3/test/utils"
"github.com/containers/storage/pkg/stringid" "github.com/containers/storage/pkg/stringid"

View File

@ -12,8 +12,8 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/storage/pkg/archive" "github.com/containers/storage/pkg/archive"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -11,7 +11,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containers/podman/v3/pkg/cgroups" "github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/rootless"
systemdDbus "github.com/coreos/go-systemd/v22/dbus" systemdDbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"

View File

@ -3,6 +3,7 @@ package cgroups
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"context"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
@ -11,7 +12,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/containers/podman/v3/pkg/rootless" "github.com/containers/storage/pkg/unshare"
systemdDbus "github.com/coreos/go-systemd/v22/dbus" systemdDbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
spec "github.com/opencontainers/runtime-spec/specs-go" spec "github.com/opencontainers/runtime-spec/specs-go"
@ -131,12 +132,12 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
controllers := []controller{} controllers := []controller{}
controllersFile := cgroupRoot + "/cgroup.controllers" controllersFile := cgroupRoot + "/cgroup.controllers"
// rootless cgroupv2: check available controllers for current user, systemd or servicescope will inherit // rootless cgroupv2: check available controllers for current user, systemd or servicescope will inherit
if rootless.IsRootless() { if unshare.IsRootless() {
userSlice, err := getCgroupPathForCurrentProcess() userSlice, err := getCgroupPathForCurrentProcess()
if err != nil { if err != nil {
return controllers, err return controllers, err
} }
//userSlice already contains '/' so not adding here // userSlice already contains '/' so not adding here
basePath := cgroupRoot + userSlice basePath := cgroupRoot + userSlice
controllersFile = fmt.Sprintf("%s/cgroup.controllers", basePath) controllersFile = fmt.Sprintf("%s/cgroup.controllers", basePath)
} }
@ -157,7 +158,7 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
subsystems, _ := cgroupV1GetAllSubsystems() subsystems, _ := cgroupV1GetAllSubsystems()
controllers := []controller{} controllers := []controller{}
// cgroupv1 and rootless: No subsystem is available: delegation is unsafe. // cgroupv1 and rootless: No subsystem is available: delegation is unsafe.
if rootless.IsRootless() { if unshare.IsRootless() {
return controllers, nil return controllers, nil
} }
@ -435,7 +436,7 @@ func Load(path string) (*CgroupControl, error) {
// if there is no controller at all, raise an error // if there is no controller at all, raise an error
if !oneExists { if !oneExists {
if rootless.IsRootless() { if unshare.IsRootless() {
return nil, ErrCgroupV1Rootless return nil, ErrCgroupV1Rootless
} }
// compatible with the error code // compatible with the error code
@ -452,7 +453,7 @@ func (c *CgroupControl) CreateSystemdUnit(path string) error {
return fmt.Errorf("the cgroup controller is not using systemd") return fmt.Errorf("the cgroup controller is not using systemd")
} }
conn, err := systemdDbus.New() conn, err := systemdDbus.NewWithContext(context.TODO())
if err != nil { if err != nil {
return err return err
} }
@ -461,10 +462,10 @@ func (c *CgroupControl) CreateSystemdUnit(path string) error {
return systemdCreate(path, conn) return systemdCreate(path, conn)
} }
// GetUserConnection returns a user connection to D-BUS // GetUserConnection returns an user connection to D-BUS
func GetUserConnection(uid int) (*systemdDbus.Conn, error) { func GetUserConnection(uid int) (*systemdDbus.Conn, error) {
return systemdDbus.NewConnection(func() (*dbus.Conn, error) { return systemdDbus.NewConnection(func() (*dbus.Conn, error) {
return dbusAuthConnection(uid, dbus.SessionBusPrivateNoAutoStartup) return dbusAuthConnection(uid, dbus.SessionBusPrivate)
}) })
} }
@ -565,7 +566,7 @@ func (c *CgroupControl) DeleteByPathConn(path string, conn *systemdDbus.Conn) er
// DeleteByPath deletes the specified cgroup path // DeleteByPath deletes the specified cgroup path
func (c *CgroupControl) DeleteByPath(path string) error { func (c *CgroupControl) DeleteByPath(path string) error {
if c.systemd { if c.systemd {
conn, err := systemdDbus.New() conn, err := systemdDbus.NewWithContext(context.TODO())
if err != nil { if err != nil {
return err return err
} }

View File

@ -26,7 +26,7 @@ func cpusetCopyFileFromParent(dir, file string, cgroupv2 bool) ([]byte, error) {
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "open %s", path) return nil, errors.Wrapf(err, "open %s", path)
} }
if len(strings.Trim(string(data), "\n")) != 0 { if strings.Trim(string(data), "\n") != "" {
return data, nil return data, nil
} }
data, err = cpusetCopyFileFromParent(filepath.Dir(dir), file, cgroupv2) data, err = cpusetCopyFileFromParent(filepath.Dir(dir), file, cgroupv2)

View File

@ -1,6 +1,7 @@
package cgroups package cgroups
import ( import (
"context"
"fmt" "fmt"
"path/filepath" "path/filepath"
"strings" "strings"
@ -37,7 +38,7 @@ func systemdCreate(path string, c *systemdDbus.Conn) error {
} }
ch := make(chan string) ch := make(chan string)
_, err := c.StartTransientUnit(name, "replace", properties, ch) _, err := c.StartTransientUnitContext(context.TODO(), name, "replace", properties, ch)
if err != nil { if err != nil {
lastError = err lastError = err
continue continue
@ -70,7 +71,7 @@ func systemdDestroyConn(path string, c *systemdDbus.Conn) error {
name := filepath.Base(path) name := filepath.Base(path)
ch := make(chan string) ch := make(chan string)
_, err := c.StopUnit(name, "replace", ch) _, err := c.StopUnitContext(context.TODO(), name, "replace", ch)
if err != nil { if err != nil {
return err return err
} }

1
vendor/modules.txt vendored
View File

@ -114,6 +114,7 @@ github.com/containers/common/pkg/apparmor
github.com/containers/common/pkg/apparmor/internal/supported github.com/containers/common/pkg/apparmor/internal/supported
github.com/containers/common/pkg/auth github.com/containers/common/pkg/auth
github.com/containers/common/pkg/capabilities github.com/containers/common/pkg/capabilities
github.com/containers/common/pkg/cgroups
github.com/containers/common/pkg/cgroupv2 github.com/containers/common/pkg/cgroupv2
github.com/containers/common/pkg/chown github.com/containers/common/pkg/chown
github.com/containers/common/pkg/completion github.com/containers/common/pkg/completion