From f0fdde79d2e24db35d2272a9b3244332cab51fde Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 5 Oct 2020 20:41:53 -0700 Subject: [PATCH] libct/cg/systemd/v1: fix err check in enableKmem Commit 27d3dd3df35 ("don't fail when subsystem not mounted") added ignoring "not found" error to enableKmem, and as a result the function now tries to call Mkdir with an empty path, which results in a weird error message. For example, this is a failure from a libcontainer/integration test: > === RUN TestRunWithKernelMemorySystemd > exec_test.go:704: runContainer failed with kernel memory limit: container_linux.go:370: starting container process caused: process_linux.go:327: applying cgroup configuration for process caused: mkdir : no such file or directory I am not entirely sure if it is a good idea to silently ignore set limits, but at least let's fix the error handling. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/systemd/v1.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcontainer/cgroups/systemd/v1.go b/libcontainer/cgroups/systemd/v1.go index 25a1f3ef9..2679b9993 100644 --- a/libcontainer/cgroups/systemd/v1.go +++ b/libcontainer/cgroups/systemd/v1.go @@ -406,7 +406,10 @@ func (m *legacyManager) Set(container *configs.Config) error { func enableKmem(c *configs.Cgroup) error { path, err := getSubsystemPath(c, "memory") - if err != nil && !cgroups.IsNotFound(err) { + if err != nil { + if cgroups.IsNotFound(err) { + return nil + } return err }