You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2016/08/05 02:01:39 UTC

[2/2] mesos git commit: Fixed a bug around handling orphaned tasks in `GET_TASKS` call.

Fixed a bug around handling orphaned tasks in `GET_TASKS` call.

We erroneously wrapped the orphaned tasks loop with the loop
for known frameworks. This means that we would append the list
of orphaned tasks multiple times per framework. If there are
no active frameworks, we won't even return any orphaned tasks.

Review: https://reviews.apache.org/r/50815/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4097421e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4097421e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4097421e

Branch: refs/heads/master
Commit: 4097421e34a6b749f141b34389d7752a43793c4c
Parents: b406c4a
Author: Anand Mazumdar <an...@apache.org>
Authored: Thu Aug 4 19:00:32 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Aug 4 19:01:07 2016 -0700

----------------------------------------------------------------------
 src/master/http.cpp | 56 ++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4097421e/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index e26dc2f..52dd80b 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -3792,36 +3792,36 @@ mesos::master::Response::GetTasks Master::Http::_getTasks(
 
       getTasks.add_completed_tasks()->CopyFrom(*task);
     }
+  }
 
-    // Orphan tasks.
-    foreachvalue (const Slave* slave, master->slaves.registered) {
-      typedef hashmap<TaskID, Task*> TaskMap;
-      foreachvalue (const TaskMap& tasks, slave->tasks) {
-        foreachvalue (const Task* task, tasks) {
-          CHECK_NOTNULL(task);
-          const FrameworkID& frameworkId = task->framework_id();
-          if (!master->frameworks.registered.contains(frameworkId)) {
-            // TODO(joerg84): This logic should be simplified after
-            // a deprecation cycle starting with 1.0 as after that
-            // we can rely on `master->frameworks.recovered` containing
-            // all FrameworkInfos.
-            // Until then there are 3 cases:
-            // - No authorization enabled: show all orphaned tasks.
-            // - Authorization enabled, but no FrameworkInfo present:
-            //   do not show orphaned tasks.
-            // - Authorization enabled, FrameworkInfo present: filter
-            //   based on `approveViewTask`.
-            if (master->authorizer.isSome() &&
-               (!master->frameworks.recovered.contains(frameworkId) ||
-                !approveViewTask(
-                    tasksApprover,
-                    *task,
-                    master->frameworks.recovered[frameworkId]))) {
-              continue;
-            }
-
-            getTasks.add_orphan_tasks()->CopyFrom(*task);
+  // Orphan tasks.
+  foreachvalue (const Slave* slave, master->slaves.registered) {
+    typedef hashmap<TaskID, Task*> TaskMap;
+    foreachvalue (const TaskMap& tasks, slave->tasks) {
+      foreachvalue (const Task* task, tasks) {
+        CHECK_NOTNULL(task);
+        const FrameworkID& frameworkId = task->framework_id();
+        if (!master->frameworks.registered.contains(frameworkId)) {
+          // TODO(joerg84): This logic should be simplified after
+          // a deprecation cycle starting with 1.0 as after that
+          // we can rely on `master->frameworks.recovered` containing
+          // all FrameworkInfos.
+          // Until then there are 3 cases:
+          // - No authorization enabled: show all orphaned tasks.
+          // - Authorization enabled, but no FrameworkInfo present:
+          //   do not show orphaned tasks.
+          // - Authorization enabled, FrameworkInfo present: filter
+          //   based on `approveViewTask`.
+          if (master->authorizer.isSome() &&
+             (!master->frameworks.recovered.contains(frameworkId) ||
+              !approveViewTask(
+                  tasksApprover,
+                  *task,
+                  master->frameworks.recovered[frameworkId]))) {
+            continue;
           }
+
+          getTasks.add_orphan_tasks()->CopyFrom(*task);
         }
       }
     }