youki icon indicating copy to clipboard operation
youki copied to clipboard

Add test for cgroups_relative_memory

Open omprakaash opened this issue 1 year ago • 12 comments

Adds an integration test for cgroups_relative_memory. The only difference from the non-relative test seems to be the cgroup_path of the specified spec while testing.

omprakaash avatar Feb 15 '24 18:02 omprakaash

Codecov Report

Merging #2686 (44e7b59) into main (04f8f2d) will decrease coverage by 0.37%. Report is 64 commits behind head on main. The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2686      +/-   ##
==========================================
- Coverage   65.50%   65.13%   -0.37%     
==========================================
  Files         133      133              
  Lines       16916    17012      +96     
==========================================
  Hits        11081    11081              
- Misses       5835     5931      +96     

codecov-commenter avatar Feb 15 '24 20:02 codecov-commenter

LGTM

lengrongfu avatar Feb 18 '24 02:02 lengrongfu

Hey, as @omprakaash had mentioned in discord we seem to be skipping a check for memory cgroups validation, as done here in runtime-tools. @tsturzl do you have any idea, why we might be intentionally skipping this, or we might have just missed it originally?

If so, @omprakaash may I ask you to add that in both this and the other test? (You can do it in separate PR, we can merge this one before it)

YJDoc2 avatar Feb 20 '24 05:02 YJDoc2

@YJDoc2 Hmm, if you compare any of the integration tests to runtime-tools it seems like we're missing a similar step a few cgroups integration test I think I might have assumed there was something in check_container_created that was checking the container against the spec somehow. It's been 3 years, so I can't recall my thinking from back then.

A simple solution would be to just read the respective cgroups files and comparing them. It looks like cpu, memory, and network are all missing these checks.

There is a lot of opportunity here to create a read/write abstraction for cgroups files. Right now we just have a constant for each file name and use a write_cgroup_file utility function to write to a given path. If reading (or writing) cgroups file is going to become more useful outside the context of libcgroups crate then maybe we want a generalized abstraction to handle read/write? This would clean up the implementation and unit tests, as well as provide obvious utility to these integration tests in checking cgroups values without having to implement a lot of boilerplate. It's something I thought about introducing to make it easier to more easily swap out the kernel IO API being used which is something I've experimented with in the past. I don't know if that effort is too large to block fixing the issues with the current cgroups integration tests, but it's something I'd be interested in working on if no one else is immediately interested.

tsturzl avatar Feb 20 '24 18:02 tsturzl

I could just implement the additional checks for this test with current existing methods in this PR. Can the new abstractions be part of a separate PR later on ?

omprakaash avatar Feb 21 '24 00:02 omprakaash

@omprakaash that's probably a better immediate solution. If we can just implement something similar to what runtime tools is doing.

tsturzl avatar Feb 21 '24 00:02 tsturzl

I think I have some changes to request in this, I'll try to get to a full review soon.

YJDoc2 avatar Mar 11 '24 05:03 YJDoc2

Thank you for the review ! Will make the required changes.

omprakaash avatar Mar 20 '24 23:03 omprakaash

@omprakaash ping! There are still some review changes pending, so pinging you

YJDoc2 avatar Apr 29 '24 12:04 YJDoc2

Sorry for the delay, finally got a chance to work on this again.

omprakaash avatar May 27 '24 11:05 omprakaash

@omprakaash There seems to be a conflict. Please need to rebase.

utam0k avatar May 28 '24 12:05 utam0k