Skip to content

Commit

Permalink
Remove dependency on github.com/pkg/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pacoxu committed Jan 10, 2023
1 parent 73d9d3d commit 7853a3f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions validators/cgroup_validator_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"
"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -54,32 +53,32 @@ func (c *CgroupsValidator) Validate(spec SysSpec) (warns, errs []error) {
var st unix.Statfs_t
var err error
if err := unix.Statfs(unifiedMountpoint, &st); err != nil {
return nil, []error{errors.Wrap(err, "cannot statfs the cgroupv2 root")}
return nil, []error{fmt.Errorf("cannot statfs the cgroupv2 root: %w", err)}
}
var requiredCgroupSpec []string
var optionalCgroupSpec []string
var subsystems []string
if st.Type == unix.CGROUP2_SUPER_MAGIC {
subsystems, err = c.getCgroupV2Subsystems()
if err != nil {
return nil, []error{errors.Wrap(err, "failed to get cgroup v2 subsystems")}
return nil, []error{fmt.Errorf("failed to get cgroup v2 subsystems: %w", err)}
}
requiredCgroupSpec = spec.CgroupsV2
optionalCgroupSpec = spec.CgroupsV2Optional
} else {
subsystems, err = c.getCgroupV1Subsystems()
if err != nil {
return nil, []error{errors.Wrap(err, "failed to get cgroup v1 subsystems")}
return nil, []error{fmt.Errorf("failed to get cgroup v1 subsystems: %w", err)}
}
requiredCgroupSpec = spec.Cgroups
optionalCgroupSpec = spec.CgroupsOptional
}

if missingRequired := c.validateCgroupSubsystems(requiredCgroupSpec, subsystems, true); len(missingRequired) != 0 {
errs = []error{errors.Errorf("missing required cgroups: %s", strings.Join(missingRequired, " "))}
errs = []error{fmt.Errorf("missing required cgroups: %s", strings.Join(missingRequired, " "))}
}
if missingOptional := c.validateCgroupSubsystems(optionalCgroupSpec, subsystems, false); len(missingOptional) != 0 {
warns = []error{errors.Errorf("missing optional cgroups: %s", strings.Join(missingOptional, " "))}
warns = []error{fmt.Errorf("missing optional cgroups: %s", strings.Join(missingOptional, " "))}
}
return
}
Expand Down

0 comments on commit 7853a3f

Please sign in to comment.