Skip to content

Commit

Permalink
cgv1: do not disable cpuset manager if reserved interface already exists
Browse files Browse the repository at this point in the history
This PR fixes a bug where restarting a Nomad Client on a machine using cgroups
v1 (e.g. Ubuntu 20.04) would cause the cpuset cgroups manager to disable itself.

This is being caused by incorrectly interpreting a "file exists" error as
problematic when ensuring the reserved cpuset exists. If we get a "file exists"
error, that just means the Client was likely restarted.

Note that a machine reboot would fix the issue - the groups interfaces are
ephemoral.
  • Loading branch information
shoenig committed Mar 13, 2023
1 parent 5f37b2f commit 7d77901
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/lib/cgutil/cpuset_manager_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package cgutil

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -59,8 +60,10 @@ func NewCpusetManagerV1(cgroupParent string, _ []uint16, logger hclog.Logger) Cp

// ensure the reserved cpuset exists, but only copy the mems from the parent if creating the cgroup
if err = os.Mkdir(filepath.Join(cgroupParentPath, ReservedCpusetCgroupName), 0755); err != nil {
logger.Warn("failed to ensure reserved cpuset.cpus interface exists; disable cpuset management", "error", err)
return new(NoopCpusetManager)
if !errors.Is(err, os.ErrExist) {
logger.Warn("failed to ensure reserved cpuset.cpus interface exists; disable cpuset management", "error", err)
return new(NoopCpusetManager)
}
}

if err = cgroups.WriteFile(filepath.Join(cgroupParentPath, ReservedCpusetCgroupName), "cpuset.mems", parentMems); err != nil {
Expand Down

0 comments on commit 7d77901

Please sign in to comment.