Update vendor or containers/common moving pkg/cgroups there

[NO NEW TESTS NEEDED] This is just moving pkg/cgroups out so
existing tests should be fine.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-12-06 06:46:27 -05:00
parent 2f11e2ac53
commit 2130d18539
37 changed files with 41 additions and 70 deletions

View File

@ -8,11 +8,11 @@ import (
"strconv"
"strings"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/libpod/network/types"
"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/rootless"
"github.com/containers/podman/v3/pkg/specgen"

View File

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"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/rootless"
"github.com/pkg/errors"

View File

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"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/rootless"
"github.com/pkg/errors"

View File

@ -17,10 +17,10 @@ import (
"github.com/containers/buildah/copier"
"github.com/containers/buildah/pkg/overlay"
butil "github.com/containers/buildah/util"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/chown"
"github.com/containers/podman/v3/libpod/define"
"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/hooks"
"github.com/containers/podman/v3/pkg/hooks/exec"

View File

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

View File

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

View File

@ -22,11 +22,11 @@ import (
"text/template"
"time"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
conmonConfig "github.com/containers/conmon/runner/config"
"github.com/containers/podman/v3/libpod/define"
"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/errorhandling"
"github.com/containers/podman/v3/pkg/rootless"

View File

@ -3,9 +3,9 @@ package libpod
import (
"context"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod/define"
"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/rootless"
"github.com/pkg/errors"

View File

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

View File

@ -9,11 +9,11 @@ import (
"time"
"github.com/containers/buildah"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events"
"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/rootless"
"github.com/containers/podman/v3/pkg/specgen"

View File

@ -9,10 +9,10 @@ import (
"path/filepath"
"strings"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod/define"
"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/specgen"
spec "github.com/opencontainers/runtime-spec/specs-go"

View File

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

View File

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

View File

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

View File

@ -4,10 +4,10 @@ import (
"encoding/json"
"net/http"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
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/infra/abi"
"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"
"github.com/containers/buildah"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/manifest"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/events"
"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/domain/entities"
"github.com/containers/podman/v3/pkg/domain/entities/reports"

View File

@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/containers/common/pkg/cgroups"
"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/rootless"
"github.com/containers/podman/v3/utils"

View File

@ -8,9 +8,9 @@ import (
"os/exec"
"path/filepath"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"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/reports"
"github.com/containers/podman/v3/pkg/rootless"

View File

@ -9,9 +9,9 @@ import (
"os/signal"
"sync"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v3/cmd/podman/utils"
"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/namespaces"
"github.com/containers/podman/v3/pkg/rootless"

View File

@ -6,10 +6,10 @@ import (
"strings"
"github.com/containers/common/libimage"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod"
"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/specgen"
spec "github.com/opencontainers/runtime-spec/specs-go"

View File

@ -4,8 +4,8 @@ import (
"os"
"path/filepath"
"github.com/containers/common/pkg/cgroups"
"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/utils"
"github.com/pkg/errors"

View File

@ -5,7 +5,7 @@ import (
"os"
"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/util"
"github.com/containers/storage"

View File

@ -15,8 +15,8 @@ import (
"testing"
"time"
"github.com/containers/common/pkg/cgroups"
"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/rootless"
. "github.com/containers/podman/v3/test/utils"

View File

@ -12,7 +12,7 @@ import (
"syscall"
"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/test/utils"
"github.com/containers/storage/pkg/stringid"

View File

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

View File

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

View File

@ -3,6 +3,7 @@ package cgroups
import (
"bufio"
"bytes"
"context"
"fmt"
"io/ioutil"
"math"
@ -11,7 +12,7 @@ import (
"strconv"
"strings"
"github.com/containers/podman/v3/pkg/rootless"
"github.com/containers/storage/pkg/unshare"
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/godbus/dbus/v5"
spec "github.com/opencontainers/runtime-spec/specs-go"
@ -131,12 +132,12 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
controllers := []controller{}
controllersFile := cgroupRoot + "/cgroup.controllers"
// rootless cgroupv2: check available controllers for current user, systemd or servicescope will inherit
if rootless.IsRootless() {
if unshare.IsRootless() {
userSlice, err := getCgroupPathForCurrentProcess()
if err != nil {
return controllers, err
}
//userSlice already contains '/' so not adding here
// userSlice already contains '/' so not adding here
basePath := cgroupRoot + userSlice
controllersFile = fmt.Sprintf("%s/cgroup.controllers", basePath)
}
@ -157,7 +158,7 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
subsystems, _ := cgroupV1GetAllSubsystems()
controllers := []controller{}
// cgroupv1 and rootless: No subsystem is available: delegation is unsafe.
if rootless.IsRootless() {
if unshare.IsRootless() {
return controllers, nil
}
@ -435,7 +436,7 @@ func Load(path string) (*CgroupControl, error) {
// if there is no controller at all, raise an error
if !oneExists {
if rootless.IsRootless() {
if unshare.IsRootless() {
return nil, ErrCgroupV1Rootless
}
// 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")
}
conn, err := systemdDbus.New()
conn, err := systemdDbus.NewWithContext(context.TODO())
if err != nil {
return err
}
@ -461,10 +462,10 @@ func (c *CgroupControl) CreateSystemdUnit(path string) error {
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) {
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
func (c *CgroupControl) DeleteByPath(path string) error {
if c.systemd {
conn, err := systemdDbus.New()
conn, err := systemdDbus.NewWithContext(context.TODO())
if err != nil {
return err
}

View File

@ -26,7 +26,7 @@ func cpusetCopyFileFromParent(dir, file string, cgroupv2 bool) ([]byte, error) {
if err != nil {
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
}
data, err = cpusetCopyFileFromParent(filepath.Dir(dir), file, cgroupv2)

View File

@ -1,6 +1,7 @@
package cgroups
import (
"context"
"fmt"
"path/filepath"
"strings"
@ -37,7 +38,7 @@ func systemdCreate(path string, c *systemdDbus.Conn) error {
}
ch := make(chan string)
_, err := c.StartTransientUnit(name, "replace", properties, ch)
_, err := c.StartTransientUnitContext(context.TODO(), name, "replace", properties, ch)
if err != nil {
lastError = err
continue
@ -70,7 +71,7 @@ func systemdDestroyConn(path string, c *systemdDbus.Conn) error {
name := filepath.Base(path)
ch := make(chan string)
_, err := c.StopUnit(name, "replace", ch)
_, err := c.StopUnitContext(context.TODO(), name, "replace", ch)
if err != nil {
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/auth
github.com/containers/common/pkg/capabilities
github.com/containers/common/pkg/cgroups
github.com/containers/common/pkg/cgroupv2
github.com/containers/common/pkg/chown
github.com/containers/common/pkg/completion