Fixed a bug in docker/docker.cpp that causes unresolved symbols on OSX.
Review: https://reviews.apache.org/r/24825
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b2978a..40b9f6b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -418,6 +418,7 @@
slave/containerizer/launcher.hpp \
slave/containerizer/linux_launcher.hpp \
slave/containerizer/isolators/posix.hpp \
+ slave/containerizer/isolators/cgroups/constants.hpp \
slave/containerizer/isolators/cgroups/cpushare.hpp \
slave/containerizer/isolators/cgroups/mem.hpp \
slave/containerizer/isolators/cgroups/perf_event.hpp \
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index 73c62f9..ad5886b 100644
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -34,7 +34,9 @@
#include "docker/docker.hpp"
+#ifdef __linux__
#include "linux/cgroups.hpp"
+#endif // __linux__
#include "slave/containerizer/isolators/cgroups/cpushare.hpp"
#include "slave/containerizer/isolators/cgroups/mem.hpp"
@@ -96,6 +98,7 @@
return Docker(path);
}
+#ifdef __linux__
// Make sure that cgroups are mounted, and at least the 'cpu'
// subsystem is attached.
Result<string> hierarchy = cgroups::hierarchy("cpu");
@@ -105,6 +108,7 @@
"for the 'cpu' subsystem; you probably need "
"to mount cgroups manually!");
}
+#endif // __linux__
// Validate the version (and that we can use Docker at all).
string cmd = path + " version";
diff --git a/src/slave/containerizer/docker.cpp b/src/slave/containerizer/docker.cpp
index fe5b291..e3c29b8 100644
--- a/src/slave/containerizer/docker.cpp
+++ b/src/slave/containerizer/docker.cpp
@@ -45,8 +45,7 @@
#include "slave/containerizer/containerizer.hpp"
#include "slave/containerizer/docker.hpp"
-#include "slave/containerizer/isolators/cgroups/cpushare.hpp"
-#include "slave/containerizer/isolators/cgroups/mem.hpp"
+#include "slave/containerizer/isolators/cgroups/constants.hpp"
#include "usage/usage.hpp"
diff --git a/src/slave/containerizer/isolators/cgroups/constants.hpp b/src/slave/containerizer/isolators/cgroups/constants.hpp
new file mode 100644
index 0000000..e6df4a2
--- /dev/null
+++ b/src/slave/containerizer/isolators/cgroups/constants.hpp
@@ -0,0 +1,43 @@
+/**
+ * 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 __CGROUPS_ISOLATOR_CONSTANTS_HPP__
+#define __CGROUPS_ISOLATOR_CONSTANTS_HPP__
+
+#include <stout/bytes.hpp>
+#include <stout/duration.hpp>
+
+namespace mesos {
+namespace internal {
+namespace slave {
+
+// CPU subsystem constants.
+const uint64_t CPU_SHARES_PER_CPU = 1024;
+const uint64_t MIN_CPU_SHARES = 10;
+const Duration CPU_CFS_PERIOD = Milliseconds(100); // Linux default.
+const Duration MIN_CPU_CFS_QUOTA = Milliseconds(1);
+
+
+// Memory subsystem constants.
+const Bytes MIN_MEMORY = Megabytes(32);
+
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __CGROUPS_ISOLATOR_CONSTANTS_HPP__
diff --git a/src/slave/containerizer/isolators/cgroups/cpushare.hpp b/src/slave/containerizer/isolators/cgroups/cpushare.hpp
index 19dde35..d4df5f3 100644
--- a/src/slave/containerizer/isolators/cgroups/cpushare.hpp
+++ b/src/slave/containerizer/isolators/cgroups/cpushare.hpp
@@ -19,28 +19,18 @@
#ifndef __CPUSHARE_ISOLATOR_HPP__
#define __CPUSHARE_ISOLATOR_HPP__
-#include <mesos/resources.hpp>
-
-#include <process/future.hpp>
+#include <string>
#include <stout/hashmap.hpp>
-#include <stout/try.hpp>
#include "slave/containerizer/isolator.hpp"
-#include "slave/flags.hpp"
+#include "slave/containerizer/isolators/cgroups/constants.hpp"
namespace mesos {
namespace internal {
namespace slave {
-// CPU subsystem constants.
-const uint64_t CPU_SHARES_PER_CPU = 1024;
-const uint64_t MIN_CPU_SHARES = 10;
-const Duration CPU_CFS_PERIOD = Milliseconds(100); // Linux default.
-const Duration MIN_CPU_CFS_QUOTA = Milliseconds(1);
-
-
// Use the Linux cpu cgroup controller for cpu isolation which uses the
// Completely Fair Scheduler (CFS).
// - cpushare implements proportionally weighted scheduling.
diff --git a/src/slave/containerizer/isolators/cgroups/mem.hpp b/src/slave/containerizer/isolators/cgroups/mem.hpp
index c734dae..b1b4f5a 100644
--- a/src/slave/containerizer/isolators/cgroups/mem.hpp
+++ b/src/slave/containerizer/isolators/cgroups/mem.hpp
@@ -19,29 +19,16 @@
#ifndef __MEM_ISOLATOR_HPP__
#define __MEM_ISOLATOR_HPP__
-#include <stdint.h>
-
-#include <mesos/resources.hpp>
-
-#include <process/future.hpp>
-
-#include <stout/nothing.hpp>
-#include <stout/try.hpp>
-
-#include "mesos/resources.hpp"
+#include <stout/hashmap.hpp>
#include "slave/containerizer/isolator.hpp"
-#include "slave/flags.hpp"
+#include "slave/containerizer/isolators/cgroups/constants.hpp"
namespace mesos {
namespace internal {
namespace slave {
-// Memory subsystem constants.
-const Bytes MIN_MEMORY = Megabytes(32);
-
-
class CgroupsMemIsolatorProcess : public IsolatorProcess
{
public:
diff --git a/src/slave/containerizer/isolators/cgroups/perf_event.hpp b/src/slave/containerizer/isolators/cgroups/perf_event.hpp
index 4ceb07a..f7283d8 100644
--- a/src/slave/containerizer/isolators/cgroups/perf_event.hpp
+++ b/src/slave/containerizer/isolators/cgroups/perf_event.hpp
@@ -21,20 +21,14 @@
#include <set>
-#include "linux/perf.hpp"
-
-#include <mesos/resources.hpp>
-
-#include <process/future.hpp>
#include <process/time.hpp>
#include <stout/hashmap.hpp>
-#include <stout/try.hpp>
+
+#include "linux/perf.hpp"
#include "slave/containerizer/isolator.hpp"
-#include "slave/flags.hpp"
-
namespace mesos {
namespace internal {
namespace slave {