Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cgroups v2 support #465

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 18 additions & 18 deletions cmd/dadoo/dadoo_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ var _ = Describe("Dadoo", func() {
Describe("running dadoo", func() {
var (
processDir string
runcCmd *exec.Cmd
runcLogFile *os.File
runcLogFilePath string
stdinPipe, stdoutPipe, stderrPipe, exitPipe string
Expand Down Expand Up @@ -559,17 +560,30 @@ var _ = Describe("Dadoo", func() {
})
})

}

Describe("exec", func() {
BeforeEach(func() {
mode = "exec"

runcCmd = exec.Command("runc", "create", "--no-new-keyring", "--bundle", bundlePath, filepath.Base(bundlePath))
})

JustBeforeEach(func() {
// hangs if GinkgoWriter is attached
Expect(runcCmd.Run()).To(Succeed())
})

itRunsRunc()

Context("when the -runc-root flag is passed", func() {
BeforeEach(func() {
var err error
runcRoot, err = os.MkdirTemp("", "")
Expect(err).NotTo(HaveOccurred())
})

JustBeforeEach(func() {
// hangs if GinkgoWriter is attached
cmd := exec.Command("runc", "--root", runcRoot, "create", "--no-new-keyring", "--bundle", bundlePath, filepath.Base(bundlePath))
Expect(cmd.Run()).To(Succeed())
runcCmd = exec.Command("runc", "--root", runcRoot, "create", "--no-new-keyring", "--bundle", bundlePath, filepath.Base(bundlePath))
})

AfterEach(func() {
Expand Down Expand Up @@ -601,20 +615,6 @@ var _ = Describe("Dadoo", func() {
Eventually(sess).Should(gexec.Exit(0))
})
})
}

Describe("exec", func() {
BeforeEach(func() {
mode = "exec"
})

JustBeforeEach(func() {
// hangs if GinkgoWriter is attached
cmd := exec.Command("runc", "create", "--no-new-keyring", "--bundle", bundlePath, filepath.Base(bundlePath))
Expect(cmd.Run()).To(Succeed())
})

itRunsRunc()
})

Describe("run", func() {
Expand Down
5 changes: 5 additions & 0 deletions cmd/dadoo/dadoo_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
"syscall"
"testing"

gardencgroups "code.cloudfoundry.org/guardian/rundmc/cgroups"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/opencontainers/runc/libcontainer/cgroups"
)

var (
Expand Down Expand Up @@ -76,6 +78,9 @@ func TestDadoo(t *testing.T) {
}
}

if cgroups.IsCgroup2UnifiedMode() {
Expect(syscall.Unmount(filepath.Join(cgroupsRoot, gardencgroups.Unified), 0)).To(Succeed())
}
Expect(syscall.Unmount(cgroupsRoot, 0)).To(Succeed())
Expect(os.Remove(cgroupsRoot)).To(Succeed())
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/dadoo/main_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func setupTTYSocket(stdin io.Reader, stdout io.Writer, winszFifo io.Reader, pidF
defer socket.Close()

// Get the master file descriptor from runC.
master, err := cmsg.RecvFd(socket)
master, err := cmsg.RecvFile(socket)
if err != nil {
return
}
Expand Down
14 changes: 6 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ replace (
// TODO: when bumping to containerd 2.0, remove these pins
github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.11.7
github.com/containerd/go-runc => github.com/containerd/go-runc v1.0.0
github.com/opencontainers/runc => github.com/opencontainers/runc v1.1.14
)

require (
Expand All @@ -25,6 +24,7 @@ require (
github.com/BurntSushi/toml v1.4.0
github.com/cloudfoundry/dropsonde v1.1.0
github.com/cloudfoundry/gosigar v1.3.83
github.com/containerd/cgroups/v3 v3.0.3
github.com/containerd/containerd v1.7.24
github.com/containerd/containerd/api v1.8.0
github.com/containerd/errdefs v1.0.0
Expand All @@ -36,6 +36,7 @@ require (
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1
github.com/mitchellh/copystructure v1.2.0
github.com/moby/sys/user v0.3.0
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
Expand Down Expand Up @@ -65,13 +66,12 @@ require (
github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cilium/ebpf v0.11.0 // indirect
github.com/checkpoint-restore/go-criu/v6 v6.3.0 // indirect
github.com/cilium/ebpf v0.17.1 // indirect
github.com/cloudfoundry/sonde-go v0.0.0-20250107093625-3b887caf8df2 // indirect
github.com/containerd/aufs v1.0.0 // indirect
github.com/containerd/btrfs/v2 v2.0.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/containerd/continuity v0.4.5 // indirect
github.com/containerd/fifo v1.1.0 // indirect
Expand Down Expand Up @@ -128,7 +128,6 @@ require (
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/signal v0.7.1 // indirect
github.com/moby/sys/symlink v0.2.0 // indirect
github.com/moby/sys/user v0.3.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -142,13 +141,13 @@ require (
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/seccomp/libseccomp-golang v0.10.0 // indirect
github.com/smallstep/pkcs7 v0.1.1 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/tedsuo/rata v1.0.0 // indirect
github.com/urfave/cli v1.22.15 // indirect
github.com/urfave/cli v1.22.16 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.opencensus.io v0.24.0 // indirect
Expand All @@ -164,7 +163,6 @@ require (
go.opentelemetry.io/otel/trace v1.33.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
Expand Down
Loading