Created
July 24, 2018 16:54
-
-
Save jpeach/c8e1945af52f54d29387df41ebc4579c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[jpeach@jpeach mesos]$ git diff | |
diff --git a/src/slave/containerizer/mesos/isolators/xfs/disk.cpp b/src/slave/containerizer/mesos/isolators/xfs/disk.cpp | |
index 8b165bcf0..783da0407 100644 | |
--- a/src/slave/containerizer/mesos/isolators/xfs/disk.cpp | |
+++ b/src/slave/containerizer/mesos/isolators/xfs/disk.cpp | |
@@ -265,7 +265,12 @@ Future<Nothing> XfsDiskIsolatorProcess::recover( | |
infos.put(containerId, Owned<Info>(new Info(sandbox, projectId.get()))); | |
freeProjectIds -= projectId.get(); | |
- --metrics.project_ids_free; | |
+ | |
+ // The operator could have changed the project ID range, so as per | |
+ // returnProjectId(), we should only count this if is is still in range. | |
+ if (totalProjectIds.contains(projectId.get())) { | |
+ --metrics.project_ids_free; | |
+ } | |
// If this is a known orphan, the containerizer will send a cleanup call | |
// later. If this is a live container, we will manage it. Otherwise, we have | |
@@ -489,6 +494,13 @@ Future<Nothing> XfsDiskIsolatorProcess::cleanup(const ContainerID& containerId) | |
infos.erase(containerId); | |
// Schedule the directory for project ID reclaiming. | |
+ // | |
+ // We don't reclaim project ID here but wait until sandbox GC time. | |
+ // This is because the sandbox can potentially contain symlinks, | |
+ // from which we can't remove the project ID due to kernel API | |
+ // limitations. Such symlinks would then contribute to disk usage | |
+ // of another container if the project ID was reused causing small | |
+ // inaccuracies in accounting. | |
scheduledProjects.put(projectId, directory); | |
LOG(INFO) << "Removing quota from project " << projectId | |
@@ -497,24 +509,17 @@ Future<Nothing> XfsDiskIsolatorProcess::cleanup(const ContainerID& containerId) | |
Try<Nothing> quotaStatus = xfs::clearProjectQuota( | |
directory, projectId); | |
+ // Note that if we failed to clear the quota, we will still eventually | |
+ // reclaim the project ID. If there is a persistent error will the quota | |
+ // system, then we would ultimately fail to re-use that project ID since | |
+ // the quota update would fail. | |
if (quotaStatus.isError()) { | |
LOG(ERROR) << "Failed to clear quota for '" | |
<< directory << "': " << quotaStatus.error(); | |
- } | |
- | |
- // We don't reclaim project ID here and wait until sandbox GC time. | |
- // This is because the sandbox can potentially contain symlinks, from | |
- // which we can't remove project ID due to API limitations. Such | |
- // symlinks would then contribute to disk usage of another container | |
- // if the project ID was reused causing small inaccuracies in | |
- // accounting. | |
- | |
- if (quotaStatus.isError()) { | |
- freeProjectIds -= projectId; | |
return Failure("Failed to cleanup '" + directory + "'"); | |
- } else { | |
- return Nothing(); | |
} | |
+ | |
+ return Nothing(); | |
} | |
@@ -545,7 +550,7 @@ void XfsDiskIsolatorProcess::returnProjectId( | |
} | |
-void XfsDiskIsolatorProcess::checkProjectIdUsage() | |
+void XfsDiskIsolatorProcess::reclaimProjectIds() | |
{ | |
foreachpair ( | |
prid_t projectId, const string& dir, utils::copy(scheduledProjects)) { | |
@@ -579,12 +584,12 @@ void XfsDiskIsolatorProcess::initialize() | |
// Start a periodic check for which project IDs are currently in use. | |
process::loop( | |
- this->self(), | |
+ self, | |
[=]() { | |
return process::after(projectWatchInterval); | |
}, | |
[=](const Nothing&) -> process::ControlFlow<Nothing> { | |
- checkProjectIdUsage(); | |
+ reclaimProjectIds(); | |
return process::Continue(); | |
}); | |
} | |
diff --git a/src/slave/containerizer/mesos/isolators/xfs/disk.hpp b/src/slave/containerizer/mesos/isolators/xfs/disk.hpp | |
index 71221e230..38c467b47 100644 | |
--- a/src/slave/containerizer/mesos/isolators/xfs/disk.hpp | |
+++ b/src/slave/containerizer/mesos/isolators/xfs/disk.hpp | |
@@ -90,9 +90,9 @@ private: | |
// Return this project ID to the unallocated pool. | |
void returnProjectId(prid_t projectId); | |
- // Check which project IDs are currently in use and deallocate the ones that | |
- // are not. | |
- void checkProjectIdUsage(); | |
+ // Check which project IDs are currently in use and deallocate the ones | |
+ // that are not. | |
+ void reclaimProjectIds(); | |
struct Info | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment