You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2018/03/21 20:31:17 UTC

[03/11] mesos git commit: Compiled `csi.proto` when gRPC is disabled.

Compiled `csi.proto` when gRPC is disabled.

By generating `csi.pb.h` even if gRPC is disabled, other Mesos protocol
buffers can embed the CSI protocol buffers. This is required if we want
to checkpoint disk profiles in `ResourceProviderState`.

Moreover, we relaxed the precondition of compiling most files, as the
gRPC is only required by SLRP, CSI clients and the tests.

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


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

Branch: refs/heads/master
Commit: 59cca968e04dee069e0df2663733b6d6f55af0da
Parents: d68e50c
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Fri Mar 16 17:29:08 2018 -0700
Committer: Chun-Hung Hsiao <ch...@mesosphere.io>
Committed: Wed Mar 21 12:23:10 2018 -0700

----------------------------------------------------------------------
 3rdparty/Makefile.am |  4 +--
 include/csi/spec.hpp |  7 +++++
 src/CMakeLists.txt   |  3 +-
 src/Makefile.am      | 72 ++++++++++++++++++++---------------------------
 src/slave/flags.cpp  |  2 --
 src/slave/flags.hpp  |  2 --
 src/slave/slave.cpp  |  4 ---
 7 files changed, 41 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index 4347114..10b29c9 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -339,9 +339,9 @@ $(GRPC)-build-stamp:
 endif
 endif
 
-if ENABLE_GRPC
+# NOTE: We extract `csi.proto` even if gRPC is disabled because it is
+# imported by other proto files.
 ALL_LOCAL += $(CSI)-stamp
-endif
 
 # Convenience library for gmock/gtest.
 check_LTLIBRARIES = libgmock.la

http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/include/csi/spec.hpp
----------------------------------------------------------------------
diff --git a/include/csi/spec.hpp b/include/csi/spec.hpp
index df01f44..da0caae 100644
--- a/include/csi/spec.hpp
+++ b/include/csi/spec.hpp
@@ -17,8 +17,15 @@
 #ifndef __CSI_SPEC_HPP__
 #define __CSI_SPEC_HPP__
 
+// ONLY USEFUL AFTER RUNNING PROTOC.
+#include <csi/csi.pb.h>
+
+// TODO(chhsiao): Consider removing the conditional inclusion to make
+// this public header not depend on a build flag. See MESOS-8715.
+#ifdef ENABLE_GRPC
 // ONLY USEFUL AFTER RUNNING PROTOC WITH GRPC CPP PLUGIN.
 #include <csi/csi.grpc.pb.h>
+#endif // ENABLE_GRPC
 
 namespace mesos {
 namespace csi {

http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb9e9d4..750fa8a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -365,7 +365,8 @@ set(RESOURCE_PROVIDER_SRC
   resource_provider/local.cpp
   resource_provider/manager.cpp
   resource_provider/registrar.cpp
-  resource_provider/validation.cpp)
+  resource_provider/validation.cpp
+  resource_provider/storage/disk_profile.cpp)
 
 set(SCHEDULER_SRC
   sched/sched.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 8475379..1cba01b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -235,16 +235,13 @@ LDADD += -lzookeeper_mt
 endif
 
 # Set up include paths for the protocol buffer compiler.
-PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir)
-if ENABLE_GRPC
-PROTOCFLAGS += -I../$(CSI)
+PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I../$(CSI)
 
 # TODO(josephw): This is a temporary include directory which points to the
 # generated CSI protocol buffer code. Derivative protocol buffers need
 # this include in order to build. When the 3rdparty CSI repo builds its own
 # generated code, this can be changed to include that directory instead.
 MESOS_CPPFLAGS += -I../include/csi
-endif
 
 # README: we build the Mesos library out of a collection of
 # convenience libraries (that is, libraries that do not get installed
@@ -375,18 +372,20 @@ CXX_PROTOS +=								\
   slave/containerizer/mesos/isolators/network/cni/spec.pb.cc		\
   slave/containerizer/mesos/isolators/network/cni/spec.pb.h
 
-if ENABLE_GRPC
 CXX_PROTOS +=								\
   resource_provider/storage/disk_profile.pb.cc				\
   resource_provider/storage/disk_profile.pb.h
 
 CXX_CSI_PROTOS =							\
-  ../include/csi/csi.grpc.pb.cc						\
-  ../include/csi/csi.grpc.pb.h						\
   ../include/csi/csi.pb.cc						\
   ../include/csi/csi.pb.h						\
   csi/state.pb.cc							\
   csi/state.pb.h
+
+if ENABLE_GRPC
+CXX_CSI_PROTOS +=							\
+  ../include/csi/csi.grpc.pb.cc						\
+  ../include/csi/csi.grpc.pb.h
 endif
 
 CXX_LOG_PROTOS =							\
@@ -728,6 +727,7 @@ module_HEADERS =							\
   $(top_srcdir)/include/mesos/module/container_logger.hpp		\
   $(top_srcdir)/include/mesos/module/contender.hpp			\
   $(top_srcdir)/include/mesos/module/detector.hpp			\
+  $(top_srcdir)/include/mesos/module/disk_profile.hpp			\
   $(top_srcdir)/include/mesos/module/hook.hpp				\
   $(top_srcdir)/include/mesos/module/hook.proto				\
   $(top_srcdir)/include/mesos/module/http_authenticatee.hpp		\
@@ -740,11 +740,6 @@ module_HEADERS =							\
   $(top_srcdir)/include/mesos/module/secret_generator.hpp		\
   $(top_srcdir)/include/mesos/module/secret_resolver.hpp
 
-if ENABLE_GRPC
-module_HEADERS +=							\
-  $(top_srcdir)/include/mesos/module/disk_profile.hpp
-endif
-
 nodist_module_HEADERS =							\
   ../include/mesos/module/hook.pb.h					\
   ../include/mesos/module/module.pb.h
@@ -771,12 +766,8 @@ resourceproviderdir = $(pkgincludedir)/resource_provider
 
 resourceprovider_HEADERS =						\
   $(top_srcdir)/include/mesos/resource_provider/resource_provider.hpp	\
-  $(top_srcdir)/include/mesos/resource_provider/resource_provider.proto
-
-if ENABLE_GRPC
-resourceprovider_HEADERS +=						\
+  $(top_srcdir)/include/mesos/resource_provider/resource_provider.proto	\
   $(top_srcdir)/include/mesos/resource_provider/storage/disk_profile.hpp
-endif
 
 nodist_resourceprovider_HEADERS =					\
   ../include/mesos/resource_provider/resource_provider.pb.h
@@ -1470,19 +1461,17 @@ libmesos_no_3rdparty_la_SOURCES +=					\
   authentication/executor/jwt_secret_generator.hpp
 endif
 
-if ENABLE_GRPC
 libmesos_no_3rdparty_la_SOURCES +=					\
   resource_provider/storage/disk_profile.cpp				\
   resource_provider/storage/disk_profile.proto				\
   resource_provider/storage/disk_profile_utils.cpp			\
   resource_provider/storage/disk_profile_utils.hpp
 
-if OS_LINUX
+if ENABLE_GRPC
 libmesos_no_3rdparty_la_SOURCES +=					\
   resource_provider/storage/provider.cpp				\
   resource_provider/storage/provider.hpp
 endif
-endif
 
 libmesos_no_3rdparty_la_CPPFLAGS = $(MESOS_CPPFLAGS)
 
@@ -1527,25 +1516,28 @@ libbuild_la_CPPFLAGS += -DBUILD_FLAGS="\"$$BUILD_FLAGS\""
 libmesos_no_3rdparty_la_LIBADD += libbuild.la
 
 
-if ENABLE_GRPC
 # Convenience library for build the CSI client.
 noinst_LTLIBRARIES += libcsi.la
 libcsi_la_SOURCES =							\
-  csi/client.cpp							\
   csi/paths.cpp								\
   csi/utils.cpp
 libcsi_la_SOURCES +=							\
   ../include/csi/spec.hpp						\
-  csi/client.hpp							\
   csi/paths.hpp								\
   csi/state.hpp								\
   csi/state.proto							\
   csi/utils.hpp
+
+if ENABLE_GRPC
+libcsi_la_SOURCES +=							\
+  csi/client.cpp							\
+  csi/client.hpp
+endif
+
 nodist_libcsi_la_SOURCES = $(CXX_CSI_PROTOS)
 libcsi_la_CPPFLAGS = $(MESOS_CPPFLAGS)
 
 libmesos_no_3rdparty_la_LIBADD += libcsi.la
-endif
 
 
 # Convenience library for building the replicated log in order to
@@ -2298,13 +2290,11 @@ disk_full_framework_CPPFLAGS = $(MESOS_CPPFLAGS)
 disk_full_framework_LDADD = libmesos.la $(LDADD)
 
 if ENABLE_GRPC
-if OS_LINUX
 check_PROGRAMS += test-csi-plugin
 test_csi_plugin_SOURCES = examples/test_csi_plugin.cpp
 test_csi_plugin_CPPFLAGS = $(MESOS_CPPFLAGS)
 test_csi_plugin_LDADD = libmesos.la $(LIB_PROTOBUF) $(LIB_GRPC) $(LDADD)
 endif
-endif
 
 check_PROGRAMS += test-helper
 test_helper_SOURCES =						\
@@ -2352,7 +2342,6 @@ libload_qos_controller_la_CPPFLAGS = $(MESOS_CPPFLAGS)
 libload_qos_controller_la_LDFLAGS = $(MESOS_MODULE_LDFLAGS)
 
 # Library containing the URI disk profile module.
-if ENABLE_GRPC
 pkgmodule_LTLIBRARIES += liburi_disk_profile.la
 liburi_disk_profile_la_SOURCES =				\
   resource_provider/storage/uri_disk_profile.cpp		\
@@ -2360,7 +2349,6 @@ liburi_disk_profile_la_SOURCES =				\
   resource_provider/storage/disk_profile_utils.hpp
 liburi_disk_profile_la_CPPFLAGS = $(MESOS_CPPFLAGS)
 liburi_disk_profile_la_LDFLAGS = $(MESOS_MODULE_LDFLAGS)
-endif
 
 MESOS_TEST_MODULE_LDFLAGS = $(MESOS_MODULE_LDFLAGS)
 
@@ -2483,6 +2471,7 @@ mesos_tests_SOURCES =						\
   tests/cram_md5_authentication_tests.cpp			\
   tests/credentials_tests.cpp					\
   tests/default_executor_tests.cpp				\
+  tests/disk_profile_tests.cpp					\
   tests/disk_quota_tests.cpp					\
   tests/dynamic_weights_tests.cpp				\
   tests/environment.cpp						\
@@ -2589,6 +2578,13 @@ mesos_tests_SOURCES =						\
   tests/containerizer/provisioner_paths_tests.cpp		\
   tests/containerizer/volume_sandbox_path_isolator_tests.cpp
 
+if ENABLE_GRPC
+mesos_tests_SOURCES +=						\
+  tests/csi_client_tests.cpp					\
+  tests/mock_csi_plugin.cpp					\
+  tests/mock_csi_plugin.hpp
+endif
+
 if ENABLE_XFS_DISK_ISOLATOR
 mesos_tests_SOURCES +=						\
   tests/containerizer/xfs_quota_tests.cpp
@@ -2638,6 +2634,12 @@ mesos_tests_SOURCES +=						\
   tests/containerizer/volume_host_path_isolator_tests.cpp	\
   tests/containerizer/volume_image_isolator_tests.cpp		\
   tests/containerizer/volume_secret_isolator_tests.cpp
+
+if ENABLE_GRPC
+mesos_tests_SOURCES +=						\
+  tests/agent_resource_provider_config_api_tests.cpp		\
+  tests/storage_local_resource_provider_tests.cpp
+endif
 endif
 
 if ENABLE_LINUX_ROUTING
@@ -2655,20 +2657,6 @@ mesos_tests_SOURCES +=						\
   tests/containerizer/ports_isolator_tests.cpp
 endif
 
-if ENABLE_GRPC
-mesos_tests_SOURCES +=						\
-  tests/csi_client_tests.cpp					\
-  tests/mock_csi_plugin.cpp					\
-  tests/mock_csi_plugin.hpp					\
-  tests/disk_profile_tests.cpp
-
-if OS_LINUX
-mesos_tests_SOURCES +=						\
-  tests/agent_resource_provider_config_api_tests.cpp		\
-  tests/storage_local_resource_provider_tests.cpp
-endif
-endif
-
 if ENABLE_SSL
 mesos_tests_SOURCES +=						\
   tests/secret_generator_tests.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 962b07c..dd8dfb7 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -111,7 +111,6 @@ mesos::internal::slave::Flags::Flags()
       "  \"name\": \"lvm\"\n"
       "}");
 
-#ifdef ENABLE_GRPC
   add(&Flags::disk_profile_adaptor,
       "disk_profile_adaptor",
       "The name of the disk profile adaptor module that storage resource\n"
@@ -120,7 +119,6 @@ mesos::internal::slave::Flags::Flags()
       "If this flag is not specified, the default behavior for storage\n"
       "resource providers is to only expose resources for pre-existing\n"
       "volumes and not publish RAW volumes.");
-#endif
 
   add(&Flags::isolation,
       "isolation",

http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 0c67bf2..949a478 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -46,9 +46,7 @@ public:
   bool hostname_lookup;
   Option<std::string> resources;
   Option<std::string> resource_provider_config_dir;
-#ifdef ENABLE_GRPC
   Option<std::string> disk_profile_adaptor;
-#endif
   std::string isolation;
   std::string launcher;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/59cca968/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 336c906..b6dbe76 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -36,9 +36,7 @@
 
 #include <mesos/module/authenticatee.hpp>
 
-#ifdef ENABLE_GRPC
 #include <mesos/resource_provider/storage/disk_profile.hpp>
-#endif
 
 #include <process/after.hpp>
 #include <process/async.hpp>
@@ -424,7 +422,6 @@ void Slave::initialize()
       << mkdir.error();
   }
 
-#ifdef ENABLE_GRPC
   // Create the DiskProfileAdaptor module and set it globally so
   // any component that needs the module can share this instance.
   Try<DiskProfileAdaptor*> _diskProfileAdaptor =
@@ -440,7 +437,6 @@ void Slave::initialize()
     shared_ptr<DiskProfileAdaptor>(_diskProfileAdaptor.get());
 
   DiskProfileAdaptor::setAdaptor(diskProfileAdaptor);
-#endif
 
   string scheme = "http";