mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [mesos] cf-natali commented on a change in pull request #355: Handle EBUSY when destroying a cgroup.
Date Fri, 10 Apr 2020 17:17:19 GMT
cf-natali commented on a change in pull request #355: Handle EBUSY when destroying a cgroup.
URL: https://github.com/apache/mesos/pull/355#discussion_r406855125
 
 

 ##########
 File path: src/linux/cgroups.cpp
 ##########
 @@ -263,6 +265,70 @@ static Try<Nothing> cloneCpusetCpusMems(
   return Nothing();
 }
 
+
+// Removes a cgroup from a given hierachy.
+// @param   hierarchy  Path to hierarchy root.
+// @param   cgroup     Path of the cgroup relative to the hierarchy root.
+// @return  Some if the operation succeeds.
+//          Error if the operation fails.
+Future<Nothing> remove(const string& hierarchy, const string& cgroup)
+{
+  const string path = path::join(hierarchy, cgroup);
+
+  // We retry on EBUSY as a workaround for kernel bug
+  // https://lkml.org/lkml/2020/1/15/1349 and others which cause rmdir to fail
+  // with EBUSY even though the cgroup appears empty.
+
+  Duration delay;
+  int retry = 10;
+
+  return loop(
+      [=]() mutable {
+        auto timeout = process::after(delay);
+        delay = (delay == Duration()) ? Milliseconds(1) : delay * 2;
+        return timeout;
+      },
+      [=](const Nothing&) mutable -> Future<ControlFlow<Nothing>> {
+        if (::rmdir(path.c_str()) == 0) {
+          return process::Break();
+        } else if ((errno == EBUSY) && (retry > 0)) {
+          --retry;
+          return process::Continue();
+        } else {
+          // If the `cgroup` still exists in the hierarchy, treat this as
+          // an error; otherwise, treat this as a success since the `cgroup`
+          // has actually been cleaned up.
+          if (os::exists(path::join(hierarchy, cgroup))) {
+            return Failure(
+              "Failed to remove directory '" + path + "': " +
+              os::strerror(errno));
 
 Review comment:
   So I actually thought about this, but I thought it would be OK as in order to reach this
branch `stat` has to succeed, hence `errno` would be preserved.
   But I double-checked and apparently POSIX states that even in case of success, `errno`
might be clobbered.
   So it's safer to call `strerror` before, done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message