Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions validators/cgroup_validator_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package system

import (
"bufio"
"errors"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -63,14 +64,15 @@ func (c *CgroupsValidator) Validate(spec SysSpec) (warns, errs []error) {
if st.Type == unix.CGROUP2_SUPER_MAGIC {
subsystems, err = c.getCgroupV2Subsystems()
if err != nil {
return nil, []error{fmt.Errorf("failed to get cgroup v2 subsystems: %w", err)}
return nil, []error{fmt.Errorf("failed to get cgroups v2 subsystems: %w", err)}
}
requiredCgroupSpec = spec.CgroupsV2
optionalCgroupSpec = spec.CgroupsV2Optional
} else {
warns = append(warns, errors.New("cgroups v1 support is in maintenance mode, please migrate to cgroups v2"))
subsystems, err = c.getCgroupV1Subsystems()
if err != nil {
return nil, []error{fmt.Errorf("failed to get cgroup v1 subsystems: %w", err)}
return nil, []error{fmt.Errorf("failed to get cgroups v1 subsystems: %w", err)}
}
requiredCgroupSpec = spec.Cgroups
optionalCgroupSpec = spec.CgroupsOptional
Expand All @@ -80,7 +82,7 @@ func (c *CgroupsValidator) Validate(spec SysSpec) (warns, errs []error) {
errs = []error{fmt.Errorf("missing required cgroups: %s", strings.Join(missingRequired, " "))}
}
if missingOptional := c.validateCgroupSubsystems(optionalCgroupSpec, subsystems, false); len(missingOptional) != 0 {
warns = []error{fmt.Errorf("missing optional cgroups: %s", strings.Join(missingOptional, " "))}
warns = append(warns, fmt.Errorf("missing optional cgroups: %s", strings.Join(missingOptional, " ")))
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions validators/cgroup_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ func TestValidateCgroupSubsystem(t *testing.T) {
},
"missing required cgroup subsystem when pseudo hardcoded subsystems are set": {
cgroupSpec: []string{"system1", "devices", "freezer"},
subsystems: append(pseudoSubsystems),
subsystems: pseudoSubsystems,
required: true,
missing: []string{"system1"},
},
"missing optional cgroup subsystem when pseudo hardcoded subsystems are set": {
cgroupSpec: []string{"system1", "devices", "freezer"},
subsystems: append(pseudoSubsystems),
subsystems: pseudoSubsystems,
required: false,
missing: []string{"system1"},
},
Expand Down