| 751 | |
| 752 | |
| 753 | void ContainerizerTest<slave::MesosContainerizer>::TearDown() |
| 754 | { |
| 755 | MesosTest::TearDown(); |
| 756 | |
| 757 | Result<string> user = os::user(); |
| 758 | EXPECT_SOME(user); |
| 759 | |
| 760 | if (cgroups::enabled() && user.get() == "root") { |
| 761 | foreach (const string& subsystem, subsystems) { |
| 762 | string hierarchy = path::join(baseHierarchy, subsystem); |
| 763 | |
| 764 | Try<std::vector<string>> cgroups = cgroups::get(hierarchy); |
| 765 | ASSERT_SOME(cgroups); |
| 766 | |
| 767 | foreach (const string& cgroup, cgroups.get()) { |
| 768 | // Remove any cgroups that start with TEST_CGROUPS_ROOT. |
| 769 | if (strings::startsWith(cgroup, TEST_CGROUPS_ROOT)) { |
| 770 | // Cgroup destruction relies on `delay`s, |
| 771 | // so we must ensure the clock is resumed. |
| 772 | bool paused = Clock::paused(); |
| 773 | |
| 774 | if (paused) { |
| 775 | Clock::resume(); |
| 776 | } |
| 777 | |
| 778 | // Since we are tearing down the tests, kill any processes |
| 779 | // that might remain. Any remaining zombie processes will |
| 780 | // not prevent the destroy from succeeding. |
| 781 | EXPECT_SOME(cgroups::kill(hierarchy, cgroup, SIGKILL)); |
| 782 | AWAIT_READY(cgroups::destroy(hierarchy, cgroup)); |
| 783 | |
| 784 | if (paused) { |
| 785 | Clock::pause(); |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | } |
| 792 | #endif // __linux__ |
| 793 | |
| 794 | |