Skip to content

Commit

Permalink
add cgroup v1 warning as it is in maintaince mode for kube
Browse files Browse the repository at this point in the history
  • Loading branch information
pacoxu committed Jul 25, 2024
1 parent a0cb0d1 commit f66cb6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit f66cb6a

Please sign in to comment.