bmahler commented on code in PR #557:
URL: https://github.com/apache/mesos/pull/557#discussion_r1566358512
##########
src/tests/containerizer/cgroups2_tests.cpp:
##########
@@ -372,6 +372,27 @@ TEST_F(Cgroups2Test, ROOT_CGROUPS2_MemoryBytesRounding)
}
+TEST_F(Cgroups2Test, ROOT_CGROUPS2_MemoryMaximum)
+{
+ ASSERT_SOME(enable_controllers({"memory"}));
+
+ ASSERT_SOME(cgroups2::create(TEST_CGROUP));
+ ASSERT_SOME(cgroups2::controllers::enable(TEST_CGROUP, {"memory"}));
+
+ Bytes limit = Bytes(os::pagesize()) * 5;
+
+ // Does not exist for the root cgroup.
+ EXPECT_ERROR(cgroups2::memory::max(cgroups2::ROOT_CGROUP));
+ EXPECT_ERROR(cgroups2::memory::set_max(cgroups2::ROOT_CGROUP, limit));
+
+ EXPECT_SOME(cgroups2::memory::set_max(TEST_CGROUP, limit));
+ EXPECT_SOME_EQ(limit, cgroups2::memory::max(TEST_CGROUP));
+
+ EXPECT_SOME(cgroups2::memory::set_max(TEST_CGROUP, None()));
+ EXPECT_NONE(cgroups2::memory::max(TEST_CGROUP));
+}
Review Comment:
let's move this next to the minimum test
##########
src/linux/cgroups2.cpp:
##########
@@ -769,9 +769,33 @@ Try<cpu::BandwidthLimit> max(const string& cgroup)
namespace memory {
+namespace internal {
+
+// Parse a byte limit from a string.
+//
+// Format: "max" OR <u32 bytes>
+Result<Bytes> parse_bytelimit(const string& value)
+{
+ const string& trimmed = strings::trim(value);
+ if (trimmed == "max") {
+ return None();
+ }
+
+ Try<Bytes> bytes = Bytes::parse(trimmed + "B");
+ if (bytes.isError()) {
+ return Error("Invalid byte format '" + trimmed + "': " + bytes.error());
+ }
Review Comment:
let's use numify<uint64_t> rather than the B string parsing hack here
##########
src/linux/cgroups2.cpp:
##########
@@ -769,9 +769,33 @@ Try<cpu::BandwidthLimit> max(const string& cgroup)
namespace memory {
+namespace internal {
+
+// Parse a byte limit from a string.
+//
+// Format: "max" OR <u32 bytes>
Review Comment:
u64
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]