[core] Check cgroupv2 mount status#51141
Conversation
Signed-off-by: dentiny <dentinyhao@gmail.com>
israbbani
left a comment
There was a problem hiding this comment.
Looks good. I left a few small comments
Signed-off-by: dentiny <dentinyhao@gmail.com>
ae73a1a to
b7df013
Compare
| TEST(CgroupV2UtilsTest, CheckCgroupV2Mount) { | ||
| EXPECT_TRUE(IsCgroupV2MountedAsRw("/sys/fs/cgroup")); | ||
| EXPECT_FALSE(IsCgroupV2MountedAsRw("/tmp/non_existent_folder")); | ||
| } |
There was a problem hiding this comment.
there are more cases we should be testing here:
- cgroup v2 is mounted but not readable
- cgroup v2 is mounted but read only
- cgroup v2 is mounted and rw but in a different path
- cgroup v1 is mounted at the path
- cgroup v1 and v2 are both mounted
per the suggestion above, I would also change the function to return a detail message about the reason the function returns false and validate those details in this test
There was a problem hiding this comment.
let's also ensure that the test is running in an automated fashion. shouldn't require manual setup commands
There was a problem hiding this comment.
+1 to more tests and automated testing.
We can't expect everyone's local box to have the correct environment setup for this. Is there an example we can follow for:
- Tests that are only enabled in certain CI environments
- Setting up new CI environments for this project. (Docker, K8S, VM)
There was a problem hiding this comment.
there are more cases we should be testing here:
Is it something we should do in one unit test? That means you need to have root permission to mount and unmount cgroup folder.
There was a problem hiding this comment.
can you propose a holistic testing plan that will cover these cases in a way you think makes sense?
There was a problem hiding this comment.
Testing plan here: https://docs.google.com/document/d/10qM5J5rv3anKXr1S0OWDZIOk75e6auU5YF90u5EtRjo/edit?tab=t.0#heading=h.o0t94extwg3
Also discussed with Ibrahim offline on the testing cases and return values.
@edoakes, I think you get to write tests against the same binary behavior (true/false or failure/non-failure). For fatal errors, I prefer throwing the error as close to the problem as possible so you get more context for debugging. |
Fine w/ me |
Signed-off-by: dentiny <dentinyhao@gmail.com>
73b2585 to
6df11a1
Compare
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
edoakes
left a comment
There was a problem hiding this comment.
basically all style comments/nits
| } | ||
|
|
||
| TEST(CgroupV2UtilsTest, CgroupV2DirectoryNotExist) { | ||
| EXPECT_FALSE(IsCgroupV2Prepared("/tmp/non_existent_folder").ok()); |
There was a problem hiding this comment.
do we have a RAY_ASSERT_NOT_OK to match RAY_ASSERT_OK? not sure actually
There was a problem hiding this comment.
There was a problem hiding this comment.
The reason why I didn't wrote the NON_OK at first place is, for error status, we better check status code, instead of merely error or not. Updated to check error status in the latest commit.
src/ray/common/cgroup/test/cgroup_v2_utils_unprivileged_test.cc
Outdated
Show resolved
Hide resolved
|
the change to return a more detailed error message in the status looks great btw |
israbbani
left a comment
There was a problem hiding this comment.
Lgtm. A few small suggests around typos
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
This PR does two things: - Update the existing mount status check from linux command to C++ syscalls; - Add check it's cgroupv2 but not cgroupv1 gets mounted. Additional check: - I checked with cgroupv2 mounted with read-only mode, result ok ``` [/workspaces/pg_duckdb] (hjiang/fix-httpfs-semantics) postgres@5959e7653aeb$ mount | grep cgroup cgroup on /sys/fs/cgroup type cgroup2 (ro,nosuid,nodev,noexec,relatime) ``` --------- Signed-off-by: dentiny <dentinyhao@gmail.com> Signed-off-by: Dhakshin Suriakannu <d_suriakannu@apple.com>
This PR does two things:
Additional check: