[arvados] updated: 2.6.0-379-g274446da3

git repository hosting git at public.arvados.org
Tue Jul 18 20:29:17 UTC 2023


Summary of changes:
 lib/crunchrun/cgroup.go      | 7 +++++++
 lib/crunchrun/cgroup_test.go | 8 --------
 lib/crunchrun/crunchrun.go   | 2 +-
 3 files changed, 8 insertions(+), 9 deletions(-)

       via  274446da3485d30b9c03812ef11f2224dbda1b7a (commit)
      from  7f0a2efd068125a7edc57a9a8c3ed5a57d3fa9a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 274446da3485d30b9c03812ef11f2224dbda1b7a
Author: Tom Clegg <tom at curii.com>
Date:   Tue Jul 18 16:28:30 2023 -0400

    17244: Make -cgroup-parent-subsystem=X work in cgroups v2.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/crunchrun/cgroup.go b/lib/crunchrun/cgroup.go
index 48ec93b87..34dc8e40f 100644
--- a/lib/crunchrun/cgroup.go
+++ b/lib/crunchrun/cgroup.go
@@ -11,6 +11,9 @@ import (
 )
 
 // Return the current process's cgroup for the given subsystem.
+//
+// If the host has cgroups v2 and not v1 (i.e., unified mode), return
+// the current process's cgroup.
 func findCgroup(subsystem string) (string, error) {
 	subsys := []byte(subsystem)
 	cgroups, err := ioutil.ReadFile("/proc/self/cgroup")
@@ -22,6 +25,10 @@ func findCgroup(subsystem string) (string, error) {
 		if len(toks) < 3 {
 			continue
 		}
+		if len(toks[1]) == 0 && string(toks[0]) == "0" {
+			// cgroups v2: "0::$PATH"
+			return string(toks[2]), nil
+		}
 		for _, s := range bytes.Split(toks[1], []byte(",")) {
 			if bytes.Compare(s, subsys) == 0 {
 				return string(toks[2]), nil
diff --git a/lib/crunchrun/cgroup_test.go b/lib/crunchrun/cgroup_test.go
index 313ed9a25..eb87456d1 100644
--- a/lib/crunchrun/cgroup_test.go
+++ b/lib/crunchrun/cgroup_test.go
@@ -5,9 +5,6 @@
 package crunchrun
 
 import (
-	"fmt"
-	"os/exec"
-
 	. "gopkg.in/check.v1"
 )
 
@@ -16,11 +13,6 @@ type CgroupSuite struct{}
 var _ = Suite(&CgroupSuite{})
 
 func (s *CgroupSuite) TestFindCgroup(c *C) {
-	if buf, err := exec.Command("stat", "-ftc", "%T", "/sys/fs/cgroup").CombinedOutput(); err != nil {
-		c.Skip(fmt.Sprintf("cannot stat /sys/fs/cgroup: %s", err))
-	} else if string(buf) == "cgroup2fs\n" {
-		c.Skip("cannot test cgroups v1 feature because this system is using cgroups v2 unified mode")
-	}
 	for _, s := range []string{"devices", "cpu", "cpuset"} {
 		g, err := findCgroup(s)
 		if c.Check(err, IsNil) {
diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index 04fc6c0d0..de79a29ef 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -1903,7 +1903,7 @@ func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s
 	statInterval := flags.Duration("crunchstat-interval", 10*time.Second, "sampling period for periodic resource usage reporting")
 	flags.String("cgroup-root", "/sys/fs/cgroup", "path to sysfs cgroup tree (obsolete, ignored)")
 	flags.String("cgroup-parent", "docker", "name of container's parent cgroup (obsolete, ignored)")
-	cgroupParentSubsystem := flags.String("cgroup-parent-subsystem", "", "use current cgroup for given subsystem as parent cgroup for container (cgroups v1 only)")
+	cgroupParentSubsystem := flags.String("cgroup-parent-subsystem", "", "use current cgroup for given `subsystem` as parent cgroup for container (subsystem argument is only relevant for cgroups v1; in cgroups v2 / unified mode, any non-empty value means use current cgroup)")
 	caCertsPath := flags.String("ca-certs", "", "Path to TLS root certificates")
 	detach := flags.Bool("detach", false, "Detach from parent process and run in the background")
 	stdinConfig := flags.Bool("stdin-config", false, "Load config and environment variables from JSON message on stdin")

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list