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/2e309ab9 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2e309ab9 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2e309ab9 Branch: refs/heads/1.6.x Commit: 2e309ab9ea258f7814e41bf7747bf012f83db9f7 Parents: fbdb800 Author: Zhitao Li <zhitaoli...@gmail.com> Authored: Fri Jun 1 22:09:11 2018 -0700 Committer: Chun-Hung Hsiao <chhs...@mesosphere.io> Committed: Mon Jul 2 13:54:17 2018 -0700 ---------------------------------------------------------------------- src/slave/gc.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/2e309ab9/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());