Skip to content

Commit b03a8b1

Browse files
authored
[core] Fixing windows build with cgroups. Broken in cgroups 10/n. (#56626)
Broken in #56446. This should stop being possible once there's a single cgroups target exported (as highlighted in #54703). I've fixed the broken build and I've added a temporary test target that builds the noop implementations as part of Linux CI so it gets caught in premerge. --------- Signed-off-by: irabbani <israbbani@gmail.com>
1 parent 492f383 commit b03a8b1

File tree

5 files changed

+85
-1
lines changed

5 files changed

+85
-1
lines changed

src/ray/common/cgroup2/BUILD.bazel

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,33 @@ ray_cc_library(
7979
}),
8080
)
8181

82-
# Private Targets.
82+
# Private targets
83+
#
84+
# TODO(#54703): This target builds the noop implementations.
85+
# There's a corressponding test that runs on Linux and Non-Linux
86+
# CI so breakages are caught in premerge before these targets are
87+
# cleaned up at the end of the resource isolation milestone 1
88+
# project.
89+
ray_cc_library(
90+
name = "noop_cgroup_targets",
91+
srcs = [
92+
"noop_cgroup_manager.cc",
93+
"noop_sysfs_cgroup_driver.cc",
94+
],
95+
hdrs = [
96+
"cgroup_manager.h",
97+
"scoped_cgroup_operation.h",
98+
"sysfs_cgroup_driver.h",
99+
],
100+
visibility = [":__subpackages__"],
101+
deps = [
102+
":cgroup_driver_interface",
103+
":cgroup_manager_interface",
104+
"//src/ray/common:status",
105+
"//src/ray/common:status_or",
106+
],
107+
)
108+
83109
ray_cc_library(
84110
name = "fake_cgroup_driver",
85111
hdrs = [

src/ray/common/cgroup2/noop_cgroup_manager.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ StatusOr<std::unique_ptr<CgroupManager>> CgroupManager::Create(
3636
return std::unique_ptr<CgroupManager>(
3737
new CgroupManager(base_cgroup_path, node_id, std::move(cgroup_driver)));
3838
}
39+
40+
Status CgroupManager::AddProcessToSystemCgroup(const std::string &pid) {
41+
return Status::OK();
42+
}
43+
3944
} // namespace ray

src/ray/common/cgroup2/noop_sysfs_cgroup_driver.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ StatusOr<std::unordered_set<std::string>> SysFsCgroupDriver::ReadControllerFile(
7171
return std::unordered_set<std::string>{};
7272
}
7373

74+
Status SysFsCgroupDriver::AddProcessToCgroup(const std::string &cgroup,
75+
const std::string &process) {
76+
return Status::OK();
77+
}
78+
7479
} // namespace ray

src/ray/common/cgroup2/tests/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ ray_cc_test(
3939
"@com_google_googletest//:gtest_main",
4040
],
4141
)
42+
43+
# TODO(#54703): This target builds the noop implementations.
44+
# There's a corressponding test that runs on Linux and Non-Linux
45+
# CI so breakages are caught in premerge before these targets are
46+
# cleaned up at the end of the resource isolation milestone 1
47+
# project.
48+
ray_cc_test(
49+
name = "noop_cgroup_test",
50+
srcs = ["noop_cgroup_test.cc"],
51+
tags = [
52+
"team:core",
53+
],
54+
deps = [
55+
"//src/ray/common/cgroup2:noop_cgroup_targets",
56+
"@com_google_googletest//:gtest_main",
57+
],
58+
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 The Ray Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <memory>
16+
#include <utility>
17+
18+
#include "gtest/gtest.h"
19+
#include "ray/common/cgroup2/cgroup_manager.h"
20+
#include "ray/common/cgroup2/sysfs_cgroup_driver.h"
21+
#include "ray/common/status.h"
22+
namespace ray {
23+
24+
TEST(NoopCgroupTest, NoopCgroupDriverAndManagerBuildSuccessfullyOnAllPlatforms) {
25+
std::unique_ptr<SysFsCgroupDriver> sysfs_cgroup_driver =
26+
std::make_unique<SysFsCgroupDriver>();
27+
auto cgroup_manager =
28+
CgroupManager::Create("", "", 1, 1, std::move(sysfs_cgroup_driver));
29+
}
30+
31+
} // namespace ray

0 commit comments

Comments
 (0)