@@ -113,48 +113,65 @@ StatusOr<std::unique_ptr<CgroupManager>> CgroupManager::Create(
113113 return cgroup_manager;
114114}
115115
116- // TODO(#54703): This is a placeholder for cleanup. This will call
117- // CgroupDriver::DeleteCgroup.
118116void CgroupManager::RegisterDeleteCgroup (const std::string &cgroup_path) {
119- cleanup_operations_.emplace_back ([cgroup = cgroup_path]() {
120- RAY_LOG (INFO) << absl::StrFormat (" Deleting all cgroup %s." , cgroup);
117+ cleanup_operations_.emplace_back ([this , cgroup = cgroup_path]() {
118+ Status s = this ->cgroup_driver_ ->DeleteCgroup (cgroup);
119+ if (!s.ok ()) {
120+ RAY_LOG (WARNING) << absl::StrFormat (
121+ " Failed to delete cgroup %s with error %s." , cgroup, s.ToString ());
122+ }
121123 });
122124}
123125
124- // TODO(#54703): This is a placeholder for cleanup. This will call
125- // CgroupDriver::MoveAllProcesses.
126126void CgroupManager::RegisterMoveAllProcesses (const std::string &from,
127127 const std::string &to) {
128- cleanup_operations_.emplace_back ([from_cgroup = from, to_cgroup = to]() {
129- RAY_LOG (INFO) << absl::StrFormat (
130- " Moved All Processes from %s to %s." , from_cgroup, to_cgroup);
128+ cleanup_operations_.emplace_back ([this , from_cgroup = from, to_cgroup = to]() {
129+ Status s = this ->cgroup_driver_ ->MoveAllProcesses (from_cgroup, to_cgroup);
130+ if (!s.ok ()) {
131+ RAY_LOG (WARNING) << absl::StrFormat (
132+ " Failed to move all processes from %s to %s with error %s" ,
133+ from_cgroup,
134+ to_cgroup,
135+ s.ToString ());
136+ }
131137 });
132138}
133139
134- // TODO(#54703): This is a placeholder for cleanup. This will call
135- // CgroupDriver::AddConstraint(cgroup, constraint, default_value).
136140template <typename T>
137141void CgroupManager::RegisterRemoveConstraint (const std::string &cgroup,
138142 const Constraint<T> &constraint) {
139143 cleanup_operations_.emplace_back (
140- [constrained_cgroup = cgroup, constraint_to_remove = constraint]() {
141- RAY_LOG (INFO) << absl::StrFormat (
142- " Setting constraint %s to default value %lld for cgroup %s" ,
143- constraint_to_remove.name_ ,
144- constraint_to_remove.default_value_ ,
145- constrained_cgroup);
144+ [this , constrained_cgroup = cgroup, constraint_to_remove = constraint]() {
145+ std::string default_value = std::to_string (constraint_to_remove.default_value_ );
146+ Status s = this ->cgroup_driver_ ->AddConstraint (constrained_cgroup,
147+ constraint_to_remove.controller_ ,
148+ constraint_to_remove.name_ ,
149+ default_value);
150+ if (!s.ok ()) {
151+ RAY_LOG (WARNING) << absl::StrFormat (
152+ " Failed to set constraint %s=%s to default value for cgroup %s with error "
153+ " %s." ,
154+ constraint_to_remove.name_ ,
155+ default_value,
156+ constrained_cgroup,
157+ s.ToString ());
158+ }
146159 });
147160}
148161
149- // TODO(#54703): This is a placeholder for cleanup. This will call
150- // CgroupDriver::DisableController.
151- void CgroupManager::RegisterDisableController (const std::string &cgroup,
162+ void CgroupManager::RegisterDisableController (const std::string &cgroup_path,
152163 const std::string &controller) {
153- cleanup_operations_.emplace_back ([cgroup_to_clean = cgroup,
154- controller_to_disable = controller]() {
155- RAY_LOG (INFO) << absl::StrFormat (
156- " Disabling controller %s for cgroup %s." , controller_to_disable, cgroup_to_clean);
157- });
164+ cleanup_operations_.emplace_back (
165+ [this , cgroup = cgroup_path, controller_to_disable = controller]() {
166+ Status s = this ->cgroup_driver_ ->DisableController (cgroup, controller_to_disable);
167+ if (!s.ok ()) {
168+ RAY_LOG (WARNING) << absl::StrFormat (
169+ " Failed to disable controller %s for cgroup %s with error %s" ,
170+ controller_to_disable,
171+ cgroup,
172+ s.ToString ());
173+ }
174+ });
158175}
159176
160177Status CgroupManager::Initialize (int64_t system_reserved_cpu_weight,
@@ -168,11 +185,11 @@ Status CgroupManager::Initialize(int64_t system_reserved_cpu_weight,
168185 cpu_weight_constraint_.Max () - system_reserved_cpu_weight;
169186
170187 RAY_LOG (INFO) << absl::StrFormat (
171- " Initializing CgroupManager at base cgroup path at %s . Ray's cgroup "
172- " hierarchy will under the node cgroup %s . The %s controllers will be "
188+ " Initializing CgroupManager at base cgroup at '%s' . Ray's cgroup "
189+ " hierarchy will under the node cgroup at '%s' . The %s controllers will be "
173190 " enabled. "
174- " System cgroup %s will have constraints [%s=%lld, %s=%lld]. "
175- " Application cgroup %s will have constraints [%s=%lld]." ,
191+ " The system cgroup at '%s' will have constraints [%s=%lld, %s=%lld]. "
192+ " The application cgroup '%s' will have constraints [%s=%lld]." ,
176193 base_cgroup_path_,
177194 node_cgroup_path_,
178195 supported_controllers,
0 commit comments