diff --git a/src/runtime/pkg/resourcecontrol/cgroups_darwin.go b/src/runtime/pkg/resourcecontrol/cgroups_darwin.go new file mode 100644 index 0000000000..50cde8e5d0 --- /dev/null +++ b/src/runtime/pkg/resourcecontrol/cgroups_darwin.go @@ -0,0 +1,86 @@ +// Copyright (c) 2023 Apple Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// + +package resourcecontrol + +import ( + "errors" + + "github.com/opencontainers/runtime-spec/specs-go" +) + +type DarwinResourceController struct{} + +func RenameCgroupPath(path string) (string, error) { + return "", errors.New("RenameCgroupPath not supported on Darwin") +} + +func NewResourceController(path string, resources *specs.LinuxResources) (ResourceController, error) { + return &DarwinResourceController{}, nil +} + +func NewSandboxResourceController(path string, resources *specs.LinuxResources, sandboxCgroupOnly bool) (ResourceController, error) { + return &DarwinResourceController{}, nil +} + +func LoadResourceController(path string) (ResourceController, error) { + return &DarwinResourceController{}, nil +} + +func (c *DarwinResourceController) Delete() error { + return nil +} + +func (c *DarwinResourceController) Stat() (interface{}, error) { + return nil, nil +} + +func (c *DarwinResourceController) AddProcess(pid int, subsystems ...string) error { + return nil +} + +func (c *DarwinResourceController) AddThread(pid int, subsystems ...string) error { + return nil +} + +func (c *DarwinResourceController) AddTask(pid int, subsystems ...string) error { + return nil +} + +func (c *DarwinResourceController) Update(resources *specs.LinuxResources) error { + return nil +} + +func (c *DarwinResourceController) MoveTo(path string) error { + return nil +} + +func (c *DarwinResourceController) ID() string { + return "" +} + +func (c *DarwinResourceController) Parent() string { + return "" +} + +func (c *DarwinResourceController) Type() ResourceControllerType { + return DarwinResourceControllerType +} + +func (c *DarwinResourceController) AddDevice(deviceHostPath string) error { + return nil +} + +func (c *DarwinResourceController) RemoveDevice(deviceHostPath string) error { + return nil +} + +func (c *DarwinResourceController) UpdateCpuSet(cpuset, memset string) error { + return nil +} + +func (c *DarwinResourceController) Path() string { + return "" +} diff --git a/src/runtime/pkg/resourcecontrol/controller.go b/src/runtime/pkg/resourcecontrol/controller.go index f43599a7fc..e59767f5c8 100644 --- a/src/runtime/pkg/resourcecontrol/controller.go +++ b/src/runtime/pkg/resourcecontrol/controller.go @@ -25,7 +25,8 @@ func SetLogger(logger *logrus.Entry) { type ResourceControllerType string const ( - LinuxCgroups ResourceControllerType = "cgroups" + LinuxCgroups ResourceControllerType = "cgroups" + DarwinResourceControllerType ResourceControllerType = "darwin" ) // String converts a resource type to a string. diff --git a/src/runtime/pkg/resourcecontrol/utils.go b/src/runtime/pkg/resourcecontrol/utils.go index 449a89e9aa..4e1f029e04 100644 --- a/src/runtime/pkg/resourcecontrol/utils.go +++ b/src/runtime/pkg/resourcecontrol/utils.go @@ -19,6 +19,9 @@ var ( ErrCgroupMode = errors.New("cgroup controller type error") ) +// DefaultResourceControllerID runtime-determined location in the cgroups hierarchy. +const DefaultResourceControllerID = "/vc" + func DeviceToCgroupDeviceRule(device string) (*devices.Rule, error) { var st unix.Stat_t deviceRule := devices.Rule{ diff --git a/src/runtime/pkg/resourcecontrol/utils_linux.go b/src/runtime/pkg/resourcecontrol/utils_linux.go index a3e7ef7105..b3d889d865 100644 --- a/src/runtime/pkg/resourcecontrol/utils_linux.go +++ b/src/runtime/pkg/resourcecontrol/utils_linux.go @@ -17,9 +17,6 @@ import ( "github.com/opencontainers/runc/libcontainer/cgroups/systemd" ) -// DefaultResourceControllerID runtime-determined location in the cgroups hierarchy. -const DefaultResourceControllerID = "/vc" - // ValidCgroupPathV1 returns a valid cgroup path for cgroup v1. // see https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#cgroups-path func ValidCgroupPathV1(path string, systemdCgroup bool) (string, error) {