You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/07/06 18:34:16 UTC

[3/3] mesos git commit: Added filtering for orphaned tasks in `GET_TASKS` operator API.

Added filtering for orphaned tasks in `GET_TASKS` operator API.

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


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

Branch: refs/heads/master
Commit: 29f848b73287d383beb8d9d62c619f6884f866be
Parents: c1e0e4a
Author: haosdent huang <ha...@gmail.com>
Authored: Wed Jul 6 13:34:01 2016 -0500
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Jul 6 13:34:01 2016 -0500

----------------------------------------------------------------------
 src/master/http.cpp | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/29f848b7/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 9fed4de..32b15d1 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -3626,17 +3626,32 @@ Future<mesos::master::Response::GetTasks> Master::Http::_getTasks(
       }
 
       // Orphan tasks.
-      // TODO(vinod): Need to filter these tasks based on authorization! This
-      // is currently not possible because we don't have `FrameworkInfo` for
-      // these tasks. We need to either store `FrameworkInfo` for orphan
-      // tasks or persist FrameworkInfo of all frameworks in the registry.
       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);
-            if (!master->frameworks.registered.contains(
-                task->framework_id())) {
+            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);
             }
           }