Skip to content

Commit

Permalink
Merge pull request #319 from blanet/xx/fix-misspelling-WithHiearchy
Browse files Browse the repository at this point in the history
rename misspelling WithHiearchy to WithHierarchy
  • Loading branch information
estesp authored Jan 2, 2024
2 parents 1e05688 + 675b7db commit 601c1a7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Protobuild.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generators = ["go"]
# This is the default.
after = ["/usr/local/include", "/usr/include"]

# Aggregrate the API descriptors to lock down API changes.
# Aggregate the API descriptors to lock down API changes.
[[descriptors]]
prefix = "github.com/containerd/cgroups/cgroup1/stats"
target = "cgroup1/stats/metrics.pb.txt"
Expand Down
32 changes: 16 additions & 16 deletions cgroup1/cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestCreate(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestStat(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand All @@ -95,7 +95,7 @@ func TestAdd(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand All @@ -122,7 +122,7 @@ func TestAddFilteredSubsystems(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestAddTask(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand All @@ -210,7 +210,7 @@ func TestAddTaskFilteredSubsystems(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestListPids(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -295,7 +295,7 @@ func TestListTasksPids(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestLoad(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand All @@ -396,7 +396,7 @@ func TestLoad(t *testing.T) {
t.Errorf("failed to delete cgroup: %v", err)
}
}()
if control, err = Load(StaticPath("test"), WithHiearchy(mock.hierarchy)); err != nil {
if control, err = Load(StaticPath("test"), WithHierarchy(mock.hierarchy)); err != nil {
t.Error(err)
return
}
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestLoadWithMissingSubsystems(t *testing.T) {
t.Error("control is nil")
return
}
if control, err = Load(StaticPath("test"), WithHiearchy(mock.hierarchy)); err != nil {
if control, err = Load(StaticPath("test"), WithHierarchy(mock.hierarchy)); err != nil {
t.Error(err)
return
}
Expand All @@ -454,7 +454,7 @@ func TestDelete(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand All @@ -481,7 +481,7 @@ func TestCreateSubCgroup(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -523,7 +523,7 @@ func TestFreezeThaw(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down Expand Up @@ -556,7 +556,7 @@ func TestSubsystems(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand All @@ -583,7 +583,7 @@ func TestCpusetParent(t *testing.T) {
t.Errorf("failed delete: %v", err)
}
}()
control, err := New(StaticPath("/parent/child"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
control, err := New(StaticPath("/parent/child"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
if err != nil {
t.Error(err)
return
Expand Down
12 changes: 10 additions & 2 deletions cgroup1/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ func RequireDevices(s Subsystem, _ Path, _ error) error {
return ErrIgnoreSubsystem
}

// WithHiearchy sets a list of cgroup subsystems.
// WithHierarchy sets a list of cgroup subsystems.
// The default list is coming from /proc/self/mountinfo.
func WithHiearchy(h Hierarchy) InitOpts {
func WithHierarchy(h Hierarchy) InitOpts {
return func(c *InitConfig) error {
c.hierarchy = h
return nil
}
}

// WithHiearchy sets a list of cgroup subsystems. It is just kept for backward
// compatibility and will be removed in v4.
//
// Deprecated: use WithHierarchy instead.
func WithHiearchy(h Hierarchy) InitOpts {
return WithHierarchy(h)
}
4 changes: 2 additions & 2 deletions cgroup1/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ func getCgroupDestination(subsystem string) (string, error) {
return "", ErrNoCgroupMountDestination
}

func pathers(subystems []Subsystem) []pather {
func pathers(subsystems []Subsystem) []pather {
var out []pather
for _, s := range subystems {
for _, s := range subsystems {
if p, ok := s.(pather); ok {
out = append(out, p)
}
Expand Down
2 changes: 1 addition & 1 deletion cgroup2/devicefilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

// Devicefilter containes eBPF device filter program
// Devicefilter contains eBPF device filter program
//
// The implementation is based on https://github.com/containers/crun/blob/0.10.2/src/libcrun/ebpf.c
//
Expand Down
2 changes: 1 addition & 1 deletion cgroup2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (c *Manager) ToggleControllers(controllers []string, t ControllerToggle) er
}
filePath := filepath.Join(f, subtreeControl)
if err := c.writeSubtreeControl(filePath, controllers, t); err != nil {
// When running as rootless, the user may face EPERM on parent groups, but it is neglible when the
// When running as rootless, the user may face EPERM on parent groups, but it is negligible when the
// controller is already written.
// So we only return the last error.
lastErr = fmt.Errorf("failed to write subtree controllers %+v to %q: %w", controllers, filePath, err)
Expand Down

0 comments on commit 601c1a7

Please sign in to comment.