Skipped metric for non existing paths in gc. Previously, agent gc would increment the "failed" counter if the path does not exist, but this should not be an issue. This patch skipped such paths in both "failed" and "succeeded" counters.
Review: https://reviews.apache.org/r/67423 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c9958063 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c9958063 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c9958063 Branch: refs/heads/1.5.x Commit: c99580632badd28d4301278a69df5e2df1dd13f5 Parents: 0d76cc0 Author: Zhitao Li <[email protected]> Authored: Fri Jun 1 22:09:11 2018 -0700 Committer: Chun-Hung Hsiao <[email protected]> Committed: Mon Jul 2 13:56:46 2018 -0700 ---------------------------------------------------------------------- src/slave/gc.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/c9958063/src/slave/gc.cpp ---------------------------------------------------------------------- diff --git a/src/slave/gc.cpp b/src/slave/gc.cpp index 8770d88..407f6b2 100644 --- a/src/slave/gc.cpp +++ b/src/slave/gc.cpp @@ -271,11 +271,17 @@ void GarbageCollectorProcess::remove(const Timeout& removalTime) Try<Nothing> rmdir = os::rmdir(info->path, true, true, true); if (rmdir.isError()) { - LOG(WARNING) << "Failed to delete '" << info->path << "': " - << rmdir.error(); - info->promise.fail(rmdir.error()); - - ++failed; + // TODO(zhitao): Change return value type of `rmdir` to + // `Try<Nothing, ErrnoError>` and check error type instead. + if (rmdir.error() == ErrnoError(ENOENT).message) { + LOG(INFO) << "Skipped '" << info->path << "' which does not exist"; + } else { + LOG(WARNING) << "Failed to delete '" << info->path << "': " + << rmdir.error(); + info->promise.fail(rmdir.error()); + + ++failed; + } } else { LOG(INFO) << "Deleted '" << info->path << "'"; info->promise.set(rmdir.get());
