mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject [07/17] mesos git commit: Removed CgroupsCpushareIsolatorProcess.
Date Tue, 13 Sep 2016 17:54:33 GMT
Removed CgroupsCpushareIsolatorProcess.

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


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

Branch: refs/heads/master
Commit: c3d1f7761297aea52d5e5ef5fe460807a3d59b3a
Parents: e2fea32
Author: haosdent huang <haosdent@gmail.com>
Authored: Mon Sep 12 16:34:37 2016 -0700
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Tue Sep 13 10:52:01 2016 -0700

----------------------------------------------------------------------
 src/CMakeLists.txt                              |   1 -
 src/Makefile.am                                 |   2 -
 src/docker/docker.cpp                           |   2 +-
 src/slave/containerizer/mesos/containerizer.cpp |   1 -
 .../mesos/isolators/cgroups/cpushare.cpp        | 571 ---------------
 .../mesos/isolators/cgroups/cpushare.hpp        | 118 ---
 src/tests/containerizer/isolator_tests.cpp      | 725 -------------------
 7 files changed, 1 insertion(+), 1419 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 01ef494..414e723 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -159,7 +159,6 @@ set(LINUX_SRC
   slave/containerizer/mesos/linux_launcher.cpp
   slave/containerizer/mesos/isolators/appc/runtime.cpp
   slave/containerizer/mesos/isolators/cgroups/cgroups.cpp
-  slave/containerizer/mesos/isolators/cgroups/cpushare.cpp
   slave/containerizer/mesos/isolators/cgroups/devices.cpp
   slave/containerizer/mesos/isolators/cgroups/mem.cpp
   slave/containerizer/mesos/isolators/cgroups/net_cls.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 2dd7913..2ef8a21 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1025,7 +1025,6 @@ MESOS_LINUX_FILES =									\
   slave/containerizer/mesos/linux_launcher.cpp						\
   slave/containerizer/mesos/isolators/appc/runtime.cpp					\
   slave/containerizer/mesos/isolators/cgroups/cgroups.cpp				\
-  slave/containerizer/mesos/isolators/cgroups/cpushare.cpp				\
   slave/containerizer/mesos/isolators/cgroups/devices.cpp				\
   slave/containerizer/mesos/isolators/cgroups/mem.cpp					\
   slave/containerizer/mesos/isolators/cgroups/net_cls.cpp				\
@@ -1066,7 +1065,6 @@ MESOS_LINUX_FILES +=									\
   slave/containerizer/mesos/isolators/appc/runtime.hpp					\
   slave/containerizer/mesos/isolators/cgroups/cgroups.hpp				\
   slave/containerizer/mesos/isolators/cgroups/constants.hpp				\
-  slave/containerizer/mesos/isolators/cgroups/cpushare.hpp				\
   slave/containerizer/mesos/isolators/cgroups/devices.hpp				\
   slave/containerizer/mesos/isolators/cgroups/mem.hpp					\
   slave/containerizer/mesos/isolators/cgroups/net_cls.hpp				\

http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index 16abf64..44036c1 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -42,7 +42,7 @@
 #include "linux/cgroups.hpp"
 #endif // __linux__
 
-#include "slave/containerizer/mesos/isolators/cgroups/cpushare.hpp"
+#include "slave/containerizer/mesos/isolators/cgroups/constants.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/mem.hpp"
 
 #include "slave/constants.hpp"

http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 24b0585..0b240d4 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -73,7 +73,6 @@
 
 #ifdef __linux__
 #include "slave/containerizer/mesos/isolators/cgroups/cgroups.hpp"
-#include "slave/containerizer/mesos/isolators/cgroups/cpushare.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/devices.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/mem.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/net_cls.hpp"

http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/slave/containerizer/mesos/isolators/cgroups/cpushare.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/cgroups/cpushare.cpp b/src/slave/containerizer/mesos/isolators/cgroups/cpushare.cpp
deleted file mode 100644
index 221e814..0000000
--- a/src/slave/containerizer/mesos/isolators/cgroups/cpushare.cpp
+++ /dev/null
@@ -1,571 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <stdint.h>
-
-#include <mesos/type_utils.hpp>
-#include <mesos/values.hpp>
-
-#include <process/collect.hpp>
-#include <process/defer.hpp>
-#include <process/id.hpp>
-#include <process/pid.hpp>
-
-#include <stout/bytes.hpp>
-#include <stout/check.hpp>
-#include <stout/error.hpp>
-#include <stout/foreach.hpp>
-#include <stout/hashset.hpp>
-#include <stout/nothing.hpp>
-#include <stout/os.hpp>
-#include <stout/path.hpp>
-#include <stout/stringify.hpp>
-#include <stout/try.hpp>
-
-#include "linux/cgroups.hpp"
-
-#include "slave/containerizer/mesos/isolators/cgroups/cpushare.hpp"
-
-using namespace process;
-
-using std::list;
-using std::set;
-using std::string;
-using std::vector;
-
-using mesos::slave::ContainerConfig;
-using mesos::slave::ContainerLaunchInfo;
-using mesos::slave::ContainerLimitation;
-using mesos::slave::ContainerState;
-using mesos::slave::Isolator;
-
-namespace mesos {
-namespace internal {
-namespace slave {
-
-CgroupsCpushareIsolatorProcess::CgroupsCpushareIsolatorProcess(
-    const Flags& _flags,
-    const hashmap<string, string>& _hierarchies,
-    const vector<string>& _subsystems)
-  : ProcessBase(process::ID::generate("cgroups-cpushare-isolator")),
-    flags(_flags),
-    hierarchies(_hierarchies),
-    subsystems(_subsystems) {}
-
-
-CgroupsCpushareIsolatorProcess::~CgroupsCpushareIsolatorProcess() {}
-
-
-Try<Isolator*> CgroupsCpushareIsolatorProcess::create(const Flags& flags)
-{
-  Try<string> hierarchyCpu = cgroups::prepare(
-        flags.cgroups_hierarchy,
-        "cpu",
-        flags.cgroups_root);
-
-  if (hierarchyCpu.isError()) {
-    return Error(
-        "Failed to prepare hierarchy for cpu subsystem: " +
-        hierarchyCpu.error());
-  }
-
-  Try<string> hierarchyCpuacct = cgroups::prepare(
-        flags.cgroups_hierarchy,
-        "cpuacct",
-        flags.cgroups_root);
-
-  if (hierarchyCpuacct.isError()) {
-    return Error(
-        "Failed to prepare hierarchy for cpuacct subsystem: " +
-        hierarchyCpuacct.error());
-  }
-
-  hashmap<string, string> hierarchies;
-  vector<string> subsystems;
-
-  hierarchies["cpu"] = hierarchyCpu.get();
-  hierarchies["cpuacct"] = hierarchyCpuacct.get();
-
-  if (hierarchyCpu.get() == hierarchyCpuacct.get()) {
-    // Subsystem cpu and cpuacct are co-mounted (e.g., systemd).
-    hierarchies["cpu,cpuacct"] = hierarchyCpu.get();
-    subsystems.push_back("cpu,cpuacct");
-
-    // Ensure that no other subsystem is attached to the hierarchy.
-    Try<set<string>> _subsystems = cgroups::subsystems(hierarchyCpu.get());
-    if (_subsystems.isError()) {
-      return Error(
-          "Failed to get the list of attached subsystems for hierarchy " +
-          hierarchyCpu.get());
-    } else if (_subsystems.get().size() != 2) {
-      return Error(
-          "Unexpected subsystems found attached to the hierarchy " +
-          hierarchyCpu.get());
-    }
-  } else {
-    // Subsystem cpu and cpuacct are mounted separately.
-    subsystems.push_back("cpu");
-    subsystems.push_back("cpuacct");
-
-    // Ensure that no other subsystem is attached to each of the
-    // hierarchy.
-    Try<set<string>> _subsystems = cgroups::subsystems(hierarchyCpu.get());
-    if (_subsystems.isError()) {
-      return Error(
-          "Failed to get the list of attached subsystems for hierarchy " +
-          hierarchyCpu.get());
-    } else if (_subsystems.get().size() != 1) {
-      return Error(
-          "Unexpected subsystems found attached to the hierarchy " +
-          hierarchyCpu.get());
-    }
-
-    _subsystems = cgroups::subsystems(hierarchyCpuacct.get());
-    if (_subsystems.isError()) {
-      return Error(
-          "Failed to get the list of attached subsystems for hierarchy " +
-          hierarchyCpuacct.get());
-    } else if (_subsystems.get().size() != 1) {
-      return Error(
-          "Unexpected subsystems found attached to the hierarchy " +
-          hierarchyCpuacct.get());
-    }
-  }
-
-  if (flags.cgroups_enable_cfs) {
-    Try<bool> exists = cgroups::exists(
-        hierarchies["cpu"],
-        flags.cgroups_root,
-        "cpu.cfs_quota_us");
-
-    if (exists.isError() || !exists.get()) {
-      return Error(
-          "Failed to find 'cpu.cfs_quota_us'. Your kernel "
-          "might be too old to use the CFS cgroups feature.");
-    }
-  }
-
-  process::Owned<MesosIsolatorProcess> process(
-      new CgroupsCpushareIsolatorProcess(flags, hierarchies, subsystems));
-
-  return new MesosIsolator(process);
-}
-
-
-Future<Nothing> CgroupsCpushareIsolatorProcess::recover(
-    const list<ContainerState>& states,
-    const hashset<ContainerID>& orphans)
-{
-  foreach (const ContainerState& state, states) {
-    const ContainerID& containerId = state.container_id();
-    const string cgroup = path::join(flags.cgroups_root, containerId.value());
-
-    Try<bool> exists = cgroups::exists(hierarchies["cpu"], cgroup);
-    if (exists.isError()) {
-      foreachvalue (Info* info, infos) {
-        delete info;
-      }
-      infos.clear();
-      return Failure(
-          "Failed to check cgroup for container " + stringify(containerId));
-    }
-
-    if (!exists.get()) {
-      // This may occur if the executor has exited and the isolator
-      // has destroyed the cgroup but the slave dies before noticing
-      // this. This will be detected when the containerizer tries to
-      // monitor the executor's pid.
-      LOG(WARNING) << "Couldn't find cgroup for container " << containerId;
-      continue;
-    }
-
-    infos[containerId] = new Info(containerId, cgroup);
-  }
-
-  // Remove orphan cgroups.
-  foreach (const string& subsystem, subsystems) {
-    Try<vector<string>> cgroups = cgroups::get(
-        hierarchies[subsystem],
-        flags.cgroups_root);
-
-    if (cgroups.isError()) {
-      foreachvalue (Info* info, infos) {
-        delete info;
-      }
-      infos.clear();
-      return Failure(cgroups.error());
-    }
-
-    foreach (const string& cgroup, cgroups.get()) {
-      // Ignore the slave cgroup (see the --agent_subsystems flag).
-      // TODO(idownes): Remove this when the cgroups layout is
-      // updated, see MESOS-1185.
-      if (cgroup == path::join(flags.cgroups_root, "slave")) {
-        continue;
-      }
-
-      ContainerID containerId;
-      containerId.set_value(Path(cgroup).basename());
-
-      if (infos.contains(containerId)) {
-        continue;
-      }
-
-      // Known orphan cgroups will be destroyed by the containerizer
-      // using the normal cleanup path. See MESOS-2367 for details.
-      if (orphans.contains(containerId)) {
-        infos[containerId] = new Info(containerId, cgroup);
-        continue;
-      }
-
-      LOG(INFO) << "Removing unknown orphaned cgroup '"
-                << path::join(subsystem, cgroup) << "'";
-
-      // We don't wait on the destroy as we don't want to block recovery.
-      cgroups::destroy(
-          hierarchies[subsystem],
-          cgroup,
-          cgroups::DESTROY_TIMEOUT);
-    }
-  }
-
-  return Nothing();
-}
-
-
-Future<Option<ContainerLaunchInfo>> CgroupsCpushareIsolatorProcess::prepare(
-    const ContainerID& containerId,
-    const ContainerConfig& containerConfig)
-{
-  if (infos.contains(containerId)) {
-    return Failure("Container has already been prepared");
-  }
-
-  // TODO(bmahler): Don't insert into 'infos' unless we create the
-  // cgroup successfully. It's safe for now because 'cleanup' gets
-  // called if we return a Failure, but cleanup will fail because the
-  // cgroup does not exist when cgroups::destroy is called.
-  Info* info = new Info(
-      containerId, path::join(flags.cgroups_root, containerId.value()));
-
-  infos[containerId] = info;
-
-  foreach (const string& subsystem, subsystems) {
-    Try<bool> exists = cgroups::exists(hierarchies[subsystem], info->cgroup);
-    if (exists.isError()) {
-      return Failure("Failed to prepare isolator: " + exists.error());
-    } else if (exists.get()) {
-      return Failure("Failed to prepare isolator: cgroup already exists");
-    }
-
-    Try<Nothing> create = cgroups::create(hierarchies[subsystem], info->cgroup);
-    if (create.isError()) {
-      return Failure("Failed to prepare isolator: " + create.error());
-    }
-
-    // Chown the cgroup so the executor can create nested cgroups. Do
-    // not recurse so the control files are still owned by the slave
-    // user and thus cannot be changed by the executor.
-    if (containerConfig.has_user()) {
-      Try<Nothing> chown = os::chown(
-          containerConfig.user(),
-          path::join(hierarchies[subsystem], info->cgroup),
-          false);
-      if (chown.isError()) {
-        return Failure("Failed to prepare isolator: " + chown.error());
-      }
-    }
-  }
-
-  return update(containerId, containerConfig.executor_info().resources())
-    .then([]() -> Future<Option<ContainerLaunchInfo>> {
-      return None();
-    });
-}
-
-
-Future<Nothing> CgroupsCpushareIsolatorProcess::isolate(
-    const ContainerID& containerId,
-    pid_t pid)
-{
-  if (!infos.contains(containerId)) {
-    return Failure("Unknown container");
-  }
-
-  Info* info = CHECK_NOTNULL(infos[containerId]);
-
-  CHECK_NONE(info->pid);
-  info->pid = pid;
-
-  foreach (const string& subsystem, subsystems) {
-    Try<Nothing> assign = cgroups::assign(
-        hierarchies[subsystem],
-        info->cgroup,
-        pid);
-
-    if (assign.isError()) {
-      LOG(ERROR) << "Failed to assign container '" << info->containerId
-                 << " to its own cgroup '"
-                 << path::join(hierarchies[subsystem], info->cgroup)
-                 << "' : " << assign.error();
-
-      return Failure("Failed to isolate container: " + assign.error());
-    }
-  }
-
-  return Nothing();
-}
-
-
-Future<ContainerLimitation> CgroupsCpushareIsolatorProcess::watch(
-    const ContainerID& containerId)
-{
-  if (!infos.contains(containerId)) {
-    return Failure("Unknown container");
-  }
-
-  CHECK_NOTNULL(infos[containerId]);
-
-  return infos[containerId]->limitation.future();
-}
-
-
-Future<Nothing> CgroupsCpushareIsolatorProcess::update(
-    const ContainerID& containerId,
-    const Resources& resources)
-{
-  if (resources.cpus().isNone()) {
-    return Failure("No cpus resource given");
-  }
-
-  if (!infos.contains(containerId)) {
-    return Failure("Unknown container");
-  }
-
-  const Option<string>& hierarchy = hierarchies.get("cpu");
-  if (hierarchy.isNone()) {
-    return Failure("No 'cpu' hierarchy");
-  }
-
-  Info* info = CHECK_NOTNULL(infos[containerId]);
-  info->resources = resources;
-
-  double cpus = resources.cpus().get();
-
-  // Always set cpu.shares.
-  uint64_t shares;
-
-  if (flags.revocable_cpu_low_priority &&
-      resources.revocable().cpus().isSome()) {
-    shares = std::max(
-        (uint64_t) (CPU_SHARES_PER_CPU_REVOCABLE * cpus),
-        MIN_CPU_SHARES);
-  } else {
-    shares = std::max(
-        (uint64_t) (CPU_SHARES_PER_CPU * cpus),
-        MIN_CPU_SHARES);
-  }
-
-  Try<Nothing> write = cgroups::cpu::shares(
-      hierarchy.get(),
-      info->cgroup,
-      shares);
-
-  if (write.isError()) {
-    return Failure("Failed to update 'cpu.shares': " + write.error());
-  }
-
-  LOG(INFO) << "Updated 'cpu.shares' to " << shares
-            << " (cpus " << cpus << ")"
-            << " for container " << containerId;
-
-  // Set cfs quota if enabled.
-  if (flags.cgroups_enable_cfs) {
-    write = cgroups::cpu::cfs_period_us(
-        hierarchy.get(),
-        info->cgroup,
-        CPU_CFS_PERIOD);
-
-    if (write.isError()) {
-      return Failure("Failed to update 'cpu.cfs_period_us': " + write.error());
-    }
-
-    Duration quota = std::max(CPU_CFS_PERIOD * cpus, MIN_CPU_CFS_QUOTA);
-
-    write = cgroups::cpu::cfs_quota_us(hierarchy.get(), info->cgroup, quota);
-    if (write.isError()) {
-      return Failure("Failed to update 'cpu.cfs_quota_us': " + write.error());
-    }
-
-    LOG(INFO) << "Updated 'cpu.cfs_period_us' to " << CPU_CFS_PERIOD
-              << " and 'cpu.cfs_quota_us' to " << quota
-              << " (cpus " << cpus << ")"
-              << " for container " << containerId;
-  }
-
-  return Nothing();
-}
-
-
-Future<ResourceStatistics> CgroupsCpushareIsolatorProcess::usage(
-    const ContainerID& containerId)
-{
-  if (!infos.contains(containerId)) {
-    return Failure("Unknown container");
-  }
-
-  Info* info = CHECK_NOTNULL(infos[containerId]);
-
-  ResourceStatistics result;
-
-  // TODO(chzhcn): Getting the number of processes and threads is
-  // available as long as any cgroup subsystem is used so this best
-  // not be tied to a specific cgroup isolator. A better place is
-  // probably Linux Launcher, which uses the cgroup freezer subsystem.
-  // That requires some change for it to adopt the new semantics of
-  // reporting subsystem-independent cgroup usage.
-  // Note: The complexity of this operation is linear to the number of
-  // processes and threads in a container: the kernel has to allocate
-  // memory to contain the list of pids or tids; the userspace has to
-  // parse the cgroup files to get the size. If this proves to be a
-  // performance bottleneck, some kind of rate limiting mechanism
-  // needs to be employed.
-  if (flags.cgroups_cpu_enable_pids_and_tids_count) {
-    Try<std::set<pid_t>> pids =
-      cgroups::processes(hierarchies["cpuacct"], info->cgroup);
-    if (pids.isError()) {
-      return Failure("Failed to get number of processes: " + pids.error());
-    }
-
-    result.set_processes(pids.get().size());
-
-    Try<std::set<pid_t>> tids =
-      cgroups::threads(hierarchies["cpuacct"], info->cgroup);
-    if (tids.isError()) {
-      return Failure("Failed to get number of threads: " + tids.error());
-    }
-
-    result.set_threads(tids.get().size());
-  }
-
-  // Get the number of clock ticks, used for cpu accounting.
-  static long ticks = sysconf(_SC_CLK_TCK);
-
-  PCHECK(ticks > 0) << "Failed to get sysconf(_SC_CLK_TCK)";
-
-  // Add the cpuacct.stat information.
-  Try<hashmap<string, uint64_t>> stat = cgroups::stat(
-      hierarchies["cpuacct"],
-      info->cgroup,
-      "cpuacct.stat");
-
-  if (stat.isError()) {
-    return Failure("Failed to read cpuacct.stat: " + stat.error());
-  }
-
-  // TODO(bmahler): Add namespacing to cgroups to enforce the expected
-  // structure, e.g., cgroups::cpuacct::stat.
-  Option<uint64_t> user = stat.get().get("user");
-  Option<uint64_t> system = stat.get().get("system");
-
-  if (user.isSome() && system.isSome()) {
-    result.set_cpus_user_time_secs((double) user.get() / (double) ticks);
-    result.set_cpus_system_time_secs((double) system.get() / (double) ticks);
-  }
-
-  // Add the cpu.stat information only if CFS is enabled.
-  if (flags.cgroups_enable_cfs) {
-    stat = cgroups::stat(hierarchies["cpu"], info->cgroup, "cpu.stat");
-    if (stat.isError()) {
-      return Failure("Failed to read cpu.stat: " + stat.error());
-    }
-
-    Option<uint64_t> nr_periods = stat.get().get("nr_periods");
-    if (nr_periods.isSome()) {
-      result.set_cpus_nr_periods(nr_periods.get());
-    }
-
-    Option<uint64_t> nr_throttled = stat.get().get("nr_throttled");
-    if (nr_throttled.isSome()) {
-      result.set_cpus_nr_throttled(nr_throttled.get());
-    }
-
-    Option<uint64_t> throttled_time = stat.get().get("throttled_time");
-    if (throttled_time.isSome()) {
-      result.set_cpus_throttled_time_secs(
-          Nanoseconds(throttled_time.get()).secs());
-    }
-  }
-
-  return result;
-}
-
-
-Future<Nothing> CgroupsCpushareIsolatorProcess::cleanup(
-    const ContainerID& containerId)
-{
-  // Multiple calls may occur during test clean up.
-  if (!infos.contains(containerId)) {
-    VLOG(1) << "Ignoring cleanup request for unknown container: "
-            << containerId;
-
-    return Nothing();
-  }
-
-  Info* info = CHECK_NOTNULL(infos[containerId]);
-
-  list<Future<Nothing>> futures;
-  foreach (const string& subsystem, subsystems) {
-    futures.push_back(cgroups::destroy(
-        hierarchies[subsystem],
-        info->cgroup,
-        cgroups::DESTROY_TIMEOUT));
-  }
-
-  return collect(futures)
-    .onAny(defer(PID<CgroupsCpushareIsolatorProcess>(this),
-                &CgroupsCpushareIsolatorProcess::_cleanup,
-                containerId,
-                lambda::_1))
-    .then([]() { return Nothing(); });
-}
-
-
-Future<list<Nothing>> CgroupsCpushareIsolatorProcess::_cleanup(
-    const ContainerID& containerId,
-    const Future<list<Nothing>>& future)
-{
-  if (!infos.contains(containerId)) {
-    return Failure("Unknown container");
-  }
-
-  CHECK_NOTNULL(infos[containerId]);
-
-  if (!future.isReady()) {
-    return Failure(
-        "Failed to clean up container " + stringify(containerId) +
-        " : " + (future.isFailed() ? future.failure() : "discarded"));
-  }
-
-  delete infos[containerId];
-  infos.erase(containerId);
-
-  return future;
-}
-
-} // namespace slave {
-} // namespace internal {
-} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/slave/containerizer/mesos/isolators/cgroups/cpushare.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/cgroups/cpushare.hpp b/src/slave/containerizer/mesos/isolators/cgroups/cpushare.hpp
deleted file mode 100644
index 74982a6..0000000
--- a/src/slave/containerizer/mesos/isolators/cgroups/cpushare.hpp
+++ /dev/null
@@ -1,118 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef __CPUSHARE_ISOLATOR_HPP__
-#define __CPUSHARE_ISOLATOR_HPP__
-
-#include <sys/types.h>
-
-#include <string>
-#include <vector>
-
-#include <process/future.hpp>
-
-#include <stout/hashmap.hpp>
-#include <stout/option.hpp>
-
-#include "slave/flags.hpp"
-
-#include "slave/containerizer/mesos/isolator.hpp"
-
-#include "slave/containerizer/mesos/isolators/cgroups/constants.hpp"
-
-namespace mesos {
-namespace internal {
-namespace slave {
-
-// Use the Linux cpu cgroup controller for cpu isolation which uses the
-// Completely Fair Scheduler (CFS).
-// - cpushare implements proportionally weighted scheduling.
-// - cfs implements hard quota based scheduling.
-class CgroupsCpushareIsolatorProcess : public MesosIsolatorProcess
-{
-public:
-  static Try<mesos::slave::Isolator*> create(const Flags& flags);
-
-  virtual ~CgroupsCpushareIsolatorProcess();
-
-  virtual process::Future<Nothing> recover(
-      const std::list<mesos::slave::ContainerState>& states,
-      const hashset<ContainerID>& orphans);
-
-  virtual process::Future<Option<mesos::slave::ContainerLaunchInfo>> prepare(
-      const ContainerID& containerId,
-      const mesos::slave::ContainerConfig& containerConfig);
-
-  virtual process::Future<Nothing> isolate(
-      const ContainerID& containerId,
-      pid_t pid);
-
-  virtual process::Future<mesos::slave::ContainerLimitation> watch(
-      const ContainerID& containerId);
-
-  virtual process::Future<Nothing> update(
-      const ContainerID& containerId,
-      const Resources& resources);
-
-  virtual process::Future<ResourceStatistics> usage(
-      const ContainerID& containerId);
-
-  virtual process::Future<Nothing> cleanup(
-      const ContainerID& containerId);
-
-private:
-  CgroupsCpushareIsolatorProcess(
-      const Flags& flags,
-      const hashmap<std::string, std::string>& hierarchies,
-      const std::vector<std::string>& subsystems);
-
-  virtual process::Future<std::list<Nothing>> _cleanup(
-      const ContainerID& containerId,
-      const process::Future<std::list<Nothing>>& future);
-
-  struct Info
-  {
-    Info(const ContainerID& _containerId, const std::string& _cgroup)
-      : containerId(_containerId), cgroup(_cgroup) {}
-
-    const ContainerID containerId;
-    const std::string cgroup;
-    Option<pid_t> pid;
-    Option<Resources> resources;
-
-    process::Promise<mesos::slave::ContainerLimitation> limitation;
-  };
-
-  const Flags flags;
-
-  // Map from subsystem to hierarchy.
-  hashmap<std::string, std::string> hierarchies;
-
-  // Subsystems used for this isolator. Typically, there are two
-  // elements in the vector: 'cpu' and 'cpuacct'. If cpu and cpuacct
-  // systems are co-mounted (e.g., systems using systemd), then there
-  // will be only one element in the vector which is 'cpu,cpuacct'.
-  std::vector<std::string> subsystems;
-
-  // TODO(bmahler): Use Owned<Info>.
-  hashmap<ContainerID, Info*> infos;
-};
-
-} // namespace slave {
-} // namespace internal {
-} // namespace mesos {
-
-#endif // __CPUSHARE_ISOLATOR_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c3d1f776/src/tests/containerizer/isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/isolator_tests.cpp b/src/tests/containerizer/isolator_tests.cpp
index f8056ca..15978ae 100644
--- a/src/tests/containerizer/isolator_tests.cpp
+++ b/src/tests/containerizer/isolator_tests.cpp
@@ -52,8 +52,6 @@
 #include "slave/slave.hpp"
 
 #ifdef __linux__
-#include "slave/containerizer/mesos/isolators/cgroups/constants.hpp"
-#include "slave/containerizer/mesos/isolators/cgroups/cpushare.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/mem.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/net_cls.hpp"
 #include "slave/containerizer/mesos/isolators/cgroups/perf_event.hpp"
@@ -80,11 +78,9 @@ using namespace process;
 
 using mesos::internal::master::Master;
 #ifdef __linux__
-using mesos::internal::slave::CgroupsCpushareIsolatorProcess;
 using mesos::internal::slave::CgroupsMemIsolatorProcess;
 using mesos::internal::slave::CgroupsNetClsIsolatorProcess;
 using mesos::internal::slave::CgroupsPerfEventIsolatorProcess;
-using mesos::internal::slave::CPU_SHARES_PER_CPU_REVOCABLE;
 using mesos::internal::slave::Fetcher;
 using mesos::internal::slave::LinuxLauncher;
 using mesos::internal::slave::NetClsHandle;
@@ -94,7 +90,6 @@ using mesos::internal::slave::SharedFilesystemIsolatorProcess;
 using mesos::internal::slave::Launcher;
 using mesos::internal::slave::MesosContainerizer;
 using mesos::internal::slave::PosixLauncher;
-using mesos::internal::slave::PosixCpuIsolatorProcess;
 using mesos::internal::slave::PosixMemIsolatorProcess;
 using mesos::internal::slave::Slave;
 
@@ -117,321 +112,6 @@ namespace mesos {
 namespace internal {
 namespace tests {
 
-// Flag describing whether a the isolatePid parentHook should check the cgroups
-// before and after isolation.
-enum CheckCgroups
-{
-  CHECK_CGROUPS,
-  NO_CHECK_CGROUPS,
-};
-
-// A hook that is executed in the parent process. It attempts to isolate
-// a process and can optionally check the cgroups before and after isolation.
-//
-// NOTE: The child process is blocked by the hook infrastructure while
-// these hooks are executed.
-// NOTE: Returning an Error implies the child process will be killed.
-Try<Nothing> isolatePid(
-    pid_t child,
-    const Owned<Isolator>& isolator,
-    const ContainerID& containerId,
-    const CheckCgroups checkCgroups = NO_CHECK_CGROUPS)
-{
-  if (checkCgroups == CHECK_CGROUPS) {
-    // Before isolation, the cgroup is empty.
-    Future<ResourceStatistics> usage = isolator->usage(containerId);
-
-    // Note this is following the implementation of AWAIT_READY.
-    if (!process::internal::await(usage, Seconds(15))) {
-      return Error("Could check cgroup usage");
-    }
-    if (usage.isDiscarded() || usage.isFailed()) {
-      return Error("Could check cgroup usage");
-    }
-
-    if (0U != usage.get().processes()) {
-      return Error("Cgroups processes not empty before isolation");
-    }
-    if (0U != usage.get().threads()) {
-      return Error("Cgroups threads not empty before isolation");
-    }
-  }
-
-  // Isolate process.
-  Future<Nothing> isolate = isolator->isolate(containerId, child);
-
-  // Note this is following the implementation of AWAIT_READY.
-  if (!process::internal::await(isolate, Seconds(15))) {
-    return Error("Could not isolate pid");
-  }
-  if (isolate.isDiscarded() || isolate.isFailed()) {
-    return Error("Could not isolate pid");
-  }
-
-  if (checkCgroups == CHECK_CGROUPS) {
-    // After isolation, there should be one process in the cgroup.
-    Future<ResourceStatistics> usage = isolator->usage(containerId);
-
-    // Note this is following the implementation of AWAIT_READY.
-    if (!process::internal::await(usage, Seconds(15))) {
-      return Error("Could check cgroup usage");
-    }
-    if (usage.isDiscarded() || usage.isFailed()) {
-      return Error("Could check cgroup usage");
-    }
-
-    if (1U != usage.get().processes()) {
-      return Error("Cgroups processes empty after isolation");
-    }
-    if (1U != usage.get().threads()) {
-      return Error("Cgroups threads empty after isolation");
-    }
-  }
-
-  return Nothing();
-}
-
-
-template <typename T>
-class CpuIsolatorTest : public MesosTest {};
-
-
-typedef ::testing::Types<
-    PosixCpuIsolatorProcess,
-#ifdef __linux__
-    CgroupsCpushareIsolatorProcess,
-#endif // __linux__
-    tests::Module<Isolator, TestCpuIsolator>> CpuIsolatorTypes;
-
-
-TYPED_TEST_CASE(CpuIsolatorTest, CpuIsolatorTypes);
-
-
-TYPED_TEST(CpuIsolatorTest, UserCpuUsage)
-{
-  slave::Flags flags;
-
-  Try<Isolator*> _isolator = TypeParam::create(flags);
-  ASSERT_SOME(_isolator);
-  Owned<Isolator> isolator(_isolator.get());
-
-  // A PosixLauncher is sufficient even when testing a cgroups isolator.
-  Try<Launcher*> _launcher = PosixLauncher::create(flags);
-  ASSERT_SOME(_launcher);
-  Owned<Launcher> launcher(_launcher.get());
-
-  ExecutorInfo executorInfo;
-  executorInfo.mutable_resources()->CopyFrom(
-      Resources::parse("cpus:1.0").get());
-
-  ContainerID containerId;
-  containerId.set_value(UUID::random().toString());
-
-  // Use a relative temporary directory so it gets cleaned up
-  // automatically with the test.
-  Try<string> dir = os::mkdtemp(path::join(os::getcwd(), "XXXXXX"));
-  ASSERT_SOME(dir);
-
-  ContainerConfig containerConfig;
-  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
-  containerConfig.set_directory(dir.get());
-
-  AWAIT_READY(isolator->prepare(
-      containerId,
-      containerConfig));
-
-  const string& file = path::join(dir.get(), "mesos_isolator_test_ready");
-
-  // Max out a single core in userspace. This will run for at most onesecond.
-  string command = "while true ; do true ; done &"
-    "touch " + file + "; " // Signals the command is running.
-    "sleep 60";
-
-  vector<string> argv(3);
-  argv[0] = "sh";
-  argv[1] = "-c";
-  argv[2] = command;
-
-  vector<Subprocess::Hook> parentHooks;
-
-  // Create parent Hook to isolate child.
-  //
-  // NOTE: We can safely use references here as the hook will be executed
-  // during the call to `fork`.
-  const lambda::function<Try<Nothing>(pid_t)> isolatePidHook = lambda::bind(
-      isolatePid,
-      lambda::_1,
-      std::cref(isolator),
-      std::cref(containerId),
-      NO_CHECK_CGROUPS);
-
-  parentHooks.emplace_back(Subprocess::Hook(isolatePidHook));
-
-  Try<pid_t> pid = launcher->fork(
-      containerId,
-      "sh",
-      argv,
-      Subprocess::FD(STDIN_FILENO),
-      Subprocess::FD(STDOUT_FILENO),
-      Subprocess::FD(STDERR_FILENO),
-      nullptr,
-      None(),
-      None(),
-      parentHooks);
-
-  ASSERT_SOME(pid);
-
-  // Reap the forked child.
-  Future<Option<int>> status = process::reap(pid.get());
-
-  // Wait for the command to start.
-  while (!os::exists(file));
-
-  // Wait up to 1 second for the child process to induce 1/8 of a second of
-  // user cpu time.
-  ResourceStatistics statistics;
-  Duration waited = Duration::zero();
-  do {
-    Future<ResourceStatistics> usage = isolator->usage(containerId);
-    AWAIT_READY(usage);
-
-    statistics = usage.get();
-
-    // If we meet our usage expectations, we're done!
-    if (statistics.cpus_user_time_secs() >= 0.125) {
-      break;
-    }
-
-    os::sleep(Milliseconds(200));
-    waited += Milliseconds(200);
-  } while (waited < Seconds(1));
-
-  EXPECT_LE(0.125, statistics.cpus_user_time_secs());
-
-  // Ensure all processes are killed.
-  AWAIT_READY(launcher.get()->destroy(containerId));
-
-  // Make sure the child was reaped.
-  AWAIT_READY(status);
-
-  // Let the isolator clean up.
-  AWAIT_READY(isolator->cleanup(containerId));
-}
-
-
-TYPED_TEST(CpuIsolatorTest, SystemCpuUsage)
-{
-  slave::Flags flags;
-
-  Try<Isolator*> _isolator = TypeParam::create(flags);
-  ASSERT_SOME(_isolator);
-  Owned<Isolator> isolator(_isolator.get());
-
-  // A PosixLauncher is sufficient even when testing a cgroups isolator.
-  Try<Launcher*> _launcher = PosixLauncher::create(flags);
-  ASSERT_SOME(_launcher);
-  Owned<Launcher> launcher(_launcher.get());
-
-  ExecutorInfo executorInfo;
-  executorInfo.mutable_resources()->CopyFrom(
-      Resources::parse("cpus:1.0").get());
-
-  ContainerID containerId;
-  containerId.set_value(UUID::random().toString());
-
-  // Use a relative temporary directory so it gets cleaned up
-  // automatically with the test.
-  Try<string> dir = os::mkdtemp(path::join(os::getcwd(), "XXXXXX"));
-  ASSERT_SOME(dir);
-
-  ContainerConfig containerConfig;
-  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
-  containerConfig.set_directory(dir.get());
-
-  AWAIT_READY(isolator->prepare(
-      containerId,
-      containerConfig));
-
-  const string& file = path::join(dir.get(), "mesos_isolator_test_ready");
-
-  // Generating random numbers is done by the kernel and will max out a single
-  // core and run almost exclusively in the kernel, i.e., system time.
-  string command = "cat /dev/urandom > /dev/null & "
-    "touch " + file + "; " // Signals the command is running.
-    "sleep 60";
-
-  vector<string> argv(3);
-  argv[0] = "sh";
-  argv[1] = "-c";
-  argv[2] = command;
-
-  vector<Subprocess::Hook> parentHooks;
-
-  // Create parent Hook to isolate child.
-  //
-  // NOTE: We can safely use references here as the hook will be executed
-  // during the call to `fork`.
-  const lambda::function<Try<Nothing>(pid_t)> isolatePidHook = lambda::bind(
-      isolatePid,
-      lambda::_1,
-      std::cref(isolator),
-      std::cref(containerId),
-      NO_CHECK_CGROUPS);
-
-  parentHooks.emplace_back(Subprocess::Hook(isolatePidHook));
-
-  Try<pid_t> pid = launcher->fork(
-      containerId,
-      "sh",
-      argv,
-      Subprocess::FD(STDIN_FILENO),
-      Subprocess::FD(STDOUT_FILENO),
-      Subprocess::FD(STDERR_FILENO),
-      nullptr,
-      None(),
-      None(),
-      parentHooks);
-
-  ASSERT_SOME(pid);
-
-  // Reap the forked child.
-  Future<Option<int>> status = process::reap(pid.get());
-
-  // Wait for the command to start.
-  while (!os::exists(file));
-
-  // Wait up to 1 second for the child process to induce 1/8 of a second of
-  // system cpu time.
-  ResourceStatistics statistics;
-  Duration waited = Duration::zero();
-  do {
-    Future<ResourceStatistics> usage = isolator->usage(containerId);
-    AWAIT_READY(usage);
-
-    statistics = usage.get();
-
-    // If we meet our usage expectations, we're done!
-    if (statistics.cpus_system_time_secs() >= 0.125) {
-      break;
-    }
-
-    os::sleep(Milliseconds(200));
-    waited += Milliseconds(200);
-  } while (waited < Seconds(1));
-
-  EXPECT_LE(0.125, statistics.cpus_system_time_secs());
-
-  // Ensure all processes are killed.
-  AWAIT_READY(launcher.get()->destroy(containerId));
-
-  // Make sure the child was reaped.
-  AWAIT_READY(status);
-
-  // Let the isolator clean up.
-  AWAIT_READY(isolator->cleanup(containerId));
-}
-
-
 #ifdef __linux__
 class NetClsHandleManagerTest : public testing::Test {};
 
@@ -517,410 +197,6 @@ TEST_F(NetClsHandleManagerTest, SecondaryHandleRange)
 #endif // __linux__
 
 
-#ifdef __linux__
-class RevocableCpuIsolatorTest : public MesosTest {};
-
-
-TEST_F(RevocableCpuIsolatorTest, ROOT_CGROUPS_RevocableCpu)
-{
-  slave::Flags flags;
-
-  Try<Isolator*> _isolator = CgroupsCpushareIsolatorProcess::create(flags);
-  ASSERT_SOME(_isolator);
-  Owned<Isolator> isolator(_isolator.get());
-
-  Try<Launcher*> _launcher = PosixLauncher::create(flags);
-  ASSERT_SOME(_launcher);
-  Owned<Launcher> launcher(_launcher.get());
-
-  // Include revocable CPU in the executor's resources.
-  Resource cpu = Resources::parse("cpus", "1", "*").get();
-  cpu.mutable_revocable();
-
-  ExecutorInfo executorInfo;
-  executorInfo.add_resources()->CopyFrom(cpu);
-
-  ContainerID containerId;
-  containerId.set_value(UUID::random().toString());
-
-  ContainerConfig containerConfig;
-  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
-  containerConfig.set_directory(os::getcwd());
-
-  AWAIT_READY(isolator->prepare(
-        containerId,
-        containerConfig));
-
-  vector<string> argv{"sleep", "100"};
-
-  Try<pid_t> pid = launcher->fork(
-      containerId,
-      "/bin/sleep",
-      argv,
-      Subprocess::PATH("/dev/null"),
-      Subprocess::PATH("/dev/null"),
-      Subprocess::PATH("/dev/null"),
-      nullptr,
-      None(),
-      None());
-
-  ASSERT_SOME(pid);
-
-  AWAIT_READY(isolator->isolate(containerId, pid.get()));
-
-  // Executor should have proper cpu.shares for revocable containers.
-  Result<string> cpuHierarchy = cgroups::hierarchy("cpu");
-  ASSERT_SOME(cpuHierarchy);
-
-  Result<string> cpuCgroup = cgroups::cpu::cgroup(pid.get());
-  ASSERT_SOME(cpuCgroup);
-
-  EXPECT_SOME_EQ(
-      CPU_SHARES_PER_CPU_REVOCABLE,
-      cgroups::cpu::shares(cpuHierarchy.get(), cpuCgroup.get()));
-
-  // Kill the container and clean up.
-  Future<Option<int>> status = process::reap(pid.get());
-
-  AWAIT_READY(launcher.get()->destroy(containerId));
-
-  AWAIT_READY(status);
-
-  AWAIT_READY(isolator->cleanup(containerId));
-}
-#endif // __linux__
-
-
-#ifdef __linux__
-class LimitedCpuIsolatorTest : public MesosTest {};
-
-
-TEST_F(LimitedCpuIsolatorTest, ROOT_CGROUPS_CFS_Enable_Cfs)
-{
-  slave::Flags flags;
-
-  // Enable CFS to cap CPU utilization.
-  flags.cgroups_enable_cfs = true;
-
-  Try<Isolator*> _isolator = CgroupsCpushareIsolatorProcess::create(flags);
-  ASSERT_SOME(_isolator);
-  Owned<Isolator> isolator(_isolator.get());
-
-  Try<Launcher*> _launcher = LinuxLauncher::create(flags);
-  ASSERT_SOME(_launcher);
-  Owned<Launcher> launcher(_launcher.get());
-
-  // Set the executor's resources to 0.5 cpu.
-  ExecutorInfo executorInfo;
-  executorInfo.mutable_resources()->CopyFrom(
-      Resources::parse("cpus:0.5").get());
-
-  ContainerID containerId;
-  containerId.set_value(UUID::random().toString());
-
-  // Use a relative temporary directory so it gets cleaned up
-  // automatically with the test.
-  Try<string> dir = os::mkdtemp(path::join(os::getcwd(), "XXXXXX"));
-  ASSERT_SOME(dir);
-
-  ContainerConfig containerConfig;
-  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
-  containerConfig.set_directory(dir.get());
-
-  Future<Option<ContainerLaunchInfo>> prepare =
-    isolator->prepare(
-        containerId,
-        containerConfig);
-
-  AWAIT_READY(prepare);
-
-  // Generate random numbers to max out a single core. We'll run this for 0.5
-  // seconds of wall time so it should consume approximately 250 ms of total
-  // cpu time when limited to 0.5 cpu. We use /dev/urandom to prevent blocking
-  // on Linux when there's insufficient entropy.
-  string command = "cat /dev/urandom > /dev/null & "
-    "export MESOS_TEST_PID=$! && "
-    "sleep 0.5 && "
-    "kill $MESOS_TEST_PID";
-
-  vector<string> argv(3);
-  argv[0] = "sh";
-  argv[1] = "-c";
-  argv[2] = command;
-
-  vector<Subprocess::Hook> parentHooks;
-
-  // Create parent Hook to isolate child.
-  //
-  // NOTE: We can safely use references here as the hook will be executed
-  // during the call to `fork`.
-  const lambda::function<Try<Nothing>(pid_t)> isolatePidHook = lambda::bind(
-      isolatePid,
-      lambda::_1,
-      std::cref(isolator),
-      std::cref(containerId),
-      NO_CHECK_CGROUPS);
-
-  parentHooks.emplace_back(Subprocess::Hook(isolatePidHook));
-
-  Try<pid_t> pid = launcher->fork(
-      containerId,
-      "sh",
-      argv,
-      Subprocess::FD(STDIN_FILENO),
-      Subprocess::FD(STDOUT_FILENO),
-      Subprocess::FD(STDERR_FILENO),
-      nullptr,
-      None(),
-      prepare.get().isSome() ? prepare.get().get().namespaces() : 0,
-      parentHooks);
-
-  ASSERT_SOME(pid);
-
-  // Reap the forked child.
-  Future<Option<int>> status = process::reap(pid.get());
-
-  // Wait for the command to complete.
-  AWAIT_READY(status);
-
-  Future<ResourceStatistics> usage = isolator->usage(containerId);
-  AWAIT_READY(usage);
-
-  // Expect that no more than 300 ms of cpu time has been consumed. We also
-  // check that at least 50 ms of cpu time has been consumed so this test will
-  // fail if the host system is very heavily loaded. This behavior is correct
-  // because under such conditions we aren't actually testing the CFS cpu
-  // limiter.
-  double cpuTime = usage.get().cpus_system_time_secs() +
-                   usage.get().cpus_user_time_secs();
-
-  EXPECT_GE(0.30, cpuTime);
-  EXPECT_LE(0.05, cpuTime);
-
-  // Ensure all processes are killed.
-  AWAIT_READY(launcher.get()->destroy(containerId));
-
-  // Let the isolator clean up.
-  AWAIT_READY(isolator->cleanup(containerId));
-}
-
-
-// This test verifies that we can successfully launch a container with
-// a big (>= 10 cpus) cpu quota. This is to catch the regression
-// observed in MESOS-1049.
-// TODO(vinod): Revisit this if/when the isolator restricts the number
-// of cpus that an executor can use based on the slave cpus.
-TEST_F(LimitedCpuIsolatorTest, ROOT_CGROUPS_CFS_Big_Quota)
-{
-  slave::Flags flags;
-
-  // Enable CFS to cap CPU utilization.
-  flags.cgroups_enable_cfs = true;
-
-  Try<Isolator*> _isolator = CgroupsCpushareIsolatorProcess::create(flags);
-  ASSERT_SOME(_isolator);
-  Owned<Isolator> isolator(_isolator.get());
-
-  Try<Launcher*> _launcher = LinuxLauncher::create(flags);
-  ASSERT_SOME(_launcher);
-  Owned<Launcher> launcher(_launcher.get());
-
-  // Set the executor's resources to 100.5 cpu.
-  ExecutorInfo executorInfo;
-  executorInfo.mutable_resources()->CopyFrom(
-      Resources::parse("cpus:100.5").get());
-
-  ContainerID containerId;
-  containerId.set_value(UUID::random().toString());
-
-  // Use a relative temporary directory so it gets cleaned up
-  // automatically with the test.
-  Try<string> dir = os::mkdtemp(path::join(os::getcwd(), "XXXXXX"));
-  ASSERT_SOME(dir);
-
-  ContainerConfig containerConfig;
-  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
-  containerConfig.set_directory(dir.get());
-
-  Future<Option<ContainerLaunchInfo>> prepare =
-    isolator->prepare(
-        containerId,
-        containerConfig);
-
-  AWAIT_READY(prepare);
-
-  vector<string> argv(3);
-  argv[0] = "sh";
-  argv[1] = "-c";
-  argv[2] = "exit 0";
-
-  vector<Subprocess::Hook> parentHooks;
-
-  // Create parent Hook to isolate child.
-  // Note: We can safely use references here as we are sure that the life time
-  // of the parent will exceed the child.
-  const lambda::function<Try<Nothing>(pid_t)> isolatePidHook = lambda::bind(
-      isolatePid,
-      lambda::_1,
-      std::cref(isolator),
-      std::cref(containerId),
-      NO_CHECK_CGROUPS);
-
-  parentHooks.emplace_back(Subprocess::Hook(isolatePidHook));
-
-  Try<pid_t> pid = launcher->fork(
-      containerId,
-      "sh",
-      argv,
-      Subprocess::FD(STDIN_FILENO),
-      Subprocess::FD(STDOUT_FILENO),
-      Subprocess::FD(STDERR_FILENO),
-      nullptr,
-      None(),
-      prepare.get().isSome() ? prepare.get().get().namespaces() : 0,
-      parentHooks);
-
-  ASSERT_SOME(pid);
-
-  // Reap the forked child.
-  Future<Option<int>> status = process::reap(pid.get());
-
-  // Wait for the command to complete successfully.
-  AWAIT_READY(status);
-  ASSERT_SOME_EQ(0, status.get());
-
-  // Ensure all processes are killed.
-  AWAIT_READY(launcher.get()->destroy(containerId));
-
-  // Let the isolator clean up.
-  AWAIT_READY(isolator->cleanup(containerId));
-}
-
-
-// A test to verify the number of processes and threads in a
-// container.
-TEST_F(LimitedCpuIsolatorTest, ROOT_CGROUPS_Pids_and_Tids)
-{
-  slave::Flags flags;
-  flags.cgroups_cpu_enable_pids_and_tids_count = true;
-
-  Try<Isolator*> _isolator = CgroupsCpushareIsolatorProcess::create(flags);
-  ASSERT_SOME(_isolator);
-  Owned<Isolator> isolator(_isolator.get());
-
-  Try<Launcher*> _launcher = LinuxLauncher::create(flags);
-  ASSERT_SOME(_launcher);
-  Owned<Launcher> launcher(_launcher.get());
-
-  ExecutorInfo executorInfo;
-  executorInfo.mutable_resources()->CopyFrom(
-      Resources::parse("cpus:0.5;mem:512").get());
-
-  ContainerID containerId;
-  containerId.set_value(UUID::random().toString());
-
-  // Use a relative temporary directory so it gets cleaned up
-  // automatically with the test.
-  Try<string> dir = os::mkdtemp(path::join(os::getcwd(), "XXXXXX"));
-  ASSERT_SOME(dir);
-
-  ContainerConfig containerConfig;
-  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
-  containerConfig.set_directory(dir.get());
-
-  Future<Option<ContainerLaunchInfo>> prepare =
-    isolator->prepare(
-        containerId,
-        containerConfig);
-
-  AWAIT_READY(prepare);
-
-  // Right after the creation of the cgroup, which happens in
-  // 'prepare', we check that it is empty.
-  Future<ResourceStatistics> usage = isolator->usage(containerId);
-  AWAIT_READY(usage);
-  EXPECT_EQ(0U, usage.get().processes());
-  EXPECT_EQ(0U, usage.get().threads());
-
-  // Use these to communicate with the test process after it has
-  // exec'd to make sure it is running.
-  int inputPipes[2];
-  ASSERT_NE(-1, ::pipe(inputPipes));
-
-  int outputPipes[2];
-  ASSERT_NE(-1, ::pipe(outputPipes));
-
-  vector<string> argv(1);
-  argv[0] = "cat";
-
-  vector<Subprocess::Hook> parentHooks;
-
-  // Create parent Hook to isolate child.
-  // Note: We can safely use references here as we are sure that the life time
-  // of the parent will exceed the child.
-  const lambda::function<Try<Nothing>(pid_t)> isolatePidHook = lambda::bind(
-      isolatePid,
-      lambda::_1,
-      std::cref(isolator),
-      std::cref(containerId),
-      CHECK_CGROUPS);
-
-  parentHooks.emplace_back(Subprocess::Hook(isolatePidHook));
-
-  Try<pid_t> pid = launcher->fork(
-      containerId,
-      "cat",
-      argv,
-      Subprocess::FD(inputPipes[0], Subprocess::IO::OWNED),
-      Subprocess::FD(outputPipes[1], Subprocess::IO::OWNED),
-      Subprocess::FD(STDERR_FILENO),
-      nullptr,
-      None(),
-      prepare.get().isSome() ? prepare.get().get().namespaces() : 0,
-      parentHooks);
-
-  ASSERT_SOME(pid);
-
-  // Reap the forked child.
-  Future<Option<int>> status = process::reap(pid.get());
-
-  // Write to the test process and wait for an echoed result.
-  // This observation ensures that the "cat" process has
-  // completed its part of the exec() procedure and is now
-  // executing normally.
-  AWAIT_READY(io::write(inputPipes[1], "foo")
-    .then([outputPipes]() -> Future<short> {
-      return io::poll(outputPipes[0], io::READ);
-    }));
-
-  // Process count should be 1 since 'cat' is still idling.
-  usage = isolator->usage(containerId);
-  AWAIT_READY(usage);
-  EXPECT_EQ(1U, usage.get().processes());
-  EXPECT_EQ(1U, usage.get().threads());
-
-  // Ensure all processes are killed.
-  AWAIT_READY(launcher.get()->destroy(containerId));
-
-  // Clean up the extra pipes created for synchronization.
-  EXPECT_SOME(os::close(inputPipes[1]));
-  EXPECT_SOME(os::close(outputPipes[0]));
-
-  // Wait for the command to complete.
-  AWAIT_READY(status);
-
-  // After the process is killed, the cgroup should be empty again.
-  usage = isolator->usage(containerId);
-  AWAIT_READY(usage);
-  EXPECT_EQ(0U, usage.get().processes());
-  EXPECT_EQ(0U, usage.get().threads());
-
-  // Let the isolator clean up.
-  AWAIT_READY(isolator->cleanup(containerId));
-}
-#endif // __linux__
-
-
 template <typename T>
 class MemIsolatorTest : public MesosTest {};
 
@@ -1596,7 +872,6 @@ public:
 // Test all isolators that use cgroups.
 typedef ::testing::Types<
   CgroupsMemIsolatorProcess,
-  CgroupsCpushareIsolatorProcess,
   CgroupsPerfEventIsolatorProcess> CgroupsIsolatorTypes;
 
 


Mime
View raw message