You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/08/30 21:24:45 UTC
[1/2] mesos git commit: Initialize sorter pointers in
HierarchicalAllocatorProcess constructor.
Repository: mesos
Updated Branches:
refs/heads/master 037a346a2 -> 1364aa561
Initialize sorter pointers in HierarchicalAllocatorProcess constructor.
Otherwise the sorter pointers can be uninitialized if the metrics
endpoint is polled before the master is initialized.
Review: https://reviews.apache.org/r/51529
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f4e9631c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f4e9631c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f4e9631c
Branch: refs/heads/master
Commit: f4e9631ca6c35625a9bea3b298ba5f9d30478d33
Parents: 037a346
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Tue Aug 23 22:41:16 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue Aug 30 13:46:57 2016 -0700
----------------------------------------------------------------------
src/master/allocator/mesos/hierarchical.cpp | 2 --
src/master/allocator/mesos/hierarchical.hpp | 16 ++++++----------
2 files changed, 6 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f4e9631c/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index 234ef98..7dd11c2 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -143,9 +143,7 @@ void HierarchicalAllocatorProcess::initialize(
// Resources for quota'ed roles are allocated separately and prior to
// non-quota'ed roles, hence a dedicated sorter for quota'ed roles is
// necessary.
- roleSorter.reset(roleSorterFactory());
roleSorter->initialize(fairnessExcludeResourceNames);
- quotaRoleSorter.reset(quotaRoleSorterFactory());
quotaRoleSorter->initialize(fairnessExcludeResourceNames);
VLOG(1) << "Initialized hierarchical allocator process";
http://git-wip-us.apache.org/repos/asf/mesos/blob/f4e9631c/src/master/allocator/mesos/hierarchical.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.hpp b/src/master/allocator/mesos/hierarchical.hpp
index bdbc6d3..6c526ec 100644
--- a/src/master/allocator/mesos/hierarchical.hpp
+++ b/src/master/allocator/mesos/hierarchical.hpp
@@ -72,17 +72,15 @@ class HierarchicalAllocatorProcess : public MesosAllocatorProcess
{
public:
HierarchicalAllocatorProcess(
- const std::function<Sorter*()>& _roleSorterFactory,
+ const std::function<Sorter*()>& roleSorterFactory,
const std::function<Sorter*()>& _frameworkSorterFactory,
- const std::function<Sorter*()>& _quotaRoleSorterFactory)
+ const std::function<Sorter*()>& quotaRoleSorterFactory)
: initialized(false),
paused(true),
metrics(*this),
- roleSorter(nullptr),
- quotaRoleSorter(nullptr),
- roleSorterFactory(_roleSorterFactory),
- frameworkSorterFactory(_frameworkSorterFactory),
- quotaRoleSorterFactory(_quotaRoleSorterFactory) {}
+ roleSorter(roleSorterFactory()),
+ quotaRoleSorter(quotaRoleSorterFactory()),
+ frameworkSorterFactory(_frameworkSorterFactory) {}
virtual ~HierarchicalAllocatorProcess() {}
@@ -462,10 +460,8 @@ protected:
// for both the first and the second stages.
hashmap<std::string, process::Owned<Sorter>> frameworkSorters;
- // Factory functions for sorters.
- const std::function<Sorter*()> roleSorterFactory;
+ // Factory function for framework sorters.
const std::function<Sorter*()> frameworkSorterFactory;
- const std::function<Sorter*()> quotaRoleSorterFactory;
};
[2/2] mesos git commit: Added
'HierarchicalAllocatorTest.ResourceMetricsUninitialized' test.
Posted by ya...@apache.org.
Added 'HierarchicalAllocatorTest.ResourceMetricsUninitialized' test.
To test the fix (https://reviews.apache.org/r/51529/) for a
CHECK failure in HierarchicalAllocatorProcess due to uninitialized
sorter pointers.
Review: https://reviews.apache.org/r/51528
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1364aa56
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1364aa56
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1364aa56
Branch: refs/heads/master
Commit: 1364aa5617743f052f25b278d9ba931b9bb806da
Parents: f4e9631
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Tue Aug 30 09:35:06 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue Aug 30 13:59:36 2016 -0700
----------------------------------------------------------------------
src/tests/hierarchical_allocator_tests.cpp | 26 +++++++++++++++++++++++++
1 file changed, 26 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1364aa56/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index ddd4869..ad0d6f8 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -2690,6 +2690,32 @@ TEST_F(HierarchicalAllocatorTest, ResourceMetrics)
}
+// The allocator is not fully initialized until `allocator->initialize(...)`
+// is called (e.g., from `Master::initialize()` or
+// `HierarchicalAllocatorTestBase::initialize(...)`). This test
+// verifies that metrics collection works but returns empty results
+// when the allocator is uninitialized. In reality this can happen if
+// the metrics endpoint is polled before the master is initialized.
+TEST_F(HierarchicalAllocatorTest, ResourceMetricsUninitialized)
+{
+ JSON::Value metrics = Metrics();
+
+ JSON::Object expected;
+
+ // Nothing is added to the allocator or allocated.
+ expected.values = {
+ {"allocator/mesos/resources/cpus/total", 0},
+ {"allocator/mesos/resources/mem/total", 0},
+ {"allocator/mesos/resources/disk/total", 0},
+ {"allocator/mesos/resources/cpus/offered_or_allocated", 0},
+ {"allocator/mesos/resources/mem/offered_or_allocated", 0},
+ {"allocator/mesos/resources/disk/offered_or_allocated", 0},
+ };
+
+ EXPECT_TRUE(metrics.contains(expected));
+}
+
+
// This test checks that the number of times the allocation
// algorithm has run is correctly reflected in the metric.
TEST_F(HierarchicalAllocatorTest, AllocationRunsMetric)