Built storage local resource provider with CMake. This patch adds CMake rules for compiling necessary source code for building storage local resource provider and related tests.
Review: https://reviews.apache.org/r/66163/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/12a907bf Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/12a907bf Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/12a907bf Branch: refs/heads/master Commit: 12a907bf102014d31af6dd7d757ea96f5f6b4881 Parents: 8021e29 Author: Chun-Hung Hsiao <chhs...@apache.org> Authored: Fri Apr 20 18:17:53 2018 -0700 Committer: Chun-Hung Hsiao <chhs...@mesosphere.io> Committed: Fri Apr 20 18:17:53 2018 -0700 ---------------------------------------------------------------------- cmake/CompilationConfigure.cmake | 5 ++++ src/CMakeLists.txt | 33 ++++++++++++++++++----- src/examples/CMakeLists.txt | 12 +++++++++ src/resource_provider/storage/CMakeLists.txt | 21 +++++++++++++++ src/tests/CMakeLists.txt | 29 ++++++++++++++++++-- 5 files changed, 92 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/12a907bf/cmake/CompilationConfigure.cmake ---------------------------------------------------------------------- diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake index 6a218e2..843786e 100644 --- a/cmake/CompilationConfigure.cmake +++ b/cmake/CompilationConfigure.cmake @@ -478,6 +478,11 @@ add_definitions( -DVERSION="${PACKAGE_VERSION}" -DPKGDATADIR="${DATA_INSTALL_PREFIX}") +if (ENABLE_GRPC) + # TODO(chhsiao): Make this non-global. + add_definitions(-DENABLE_GRPC=1) +endif () + if (ENABLE_SSL) # TODO(andschwa): Make this non-global. add_definitions(-DUSE_SSL_SOCKET=1) http://git-wip-us.apache.org/repos/asf/mesos/blob/12a907bf/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4908cb9..d488131 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,7 @@ set(JAVA_PROTOBUF_SRC "") # # NOTE: The following `PROTOC_GENERATE` calls will list append to # `PUBLIC_PROTO_PATH`, `PUBLIC_PROTOBUF_INCLUDE_DIR` and `PUBLIC_PROTOBUF_SRC`. +# The GRPC option is a noop if gRPC is disabled. PROTOC_GENERATE(GRPC LIB csi TARGET csi) # NOTE: The following `PROTOC_GENERATE` calls will list append to @@ -84,6 +85,8 @@ PROTOC_GENERATE(INTERNAL TARGET slave/containerizer/mesos/provisioner/docker/mes PROTOC_GENERATE(INTERNAL TARGET master/registry) PROTOC_GENERATE(INTERNAL TARGET resource_provider/registry) PROTOC_GENERATE(INTERNAL TARGET resource_provider/state) +PROTOC_GENERATE(INTERNAL TARGET resource_provider/storage/disk_profile) +PROTOC_GENERATE(INTERNAL TARGET csi/state) # BUILD PROTOBUFS. @@ -104,7 +107,10 @@ add_library( ${PUBLIC_PROTOBUF_SRC} ${INTERNAL_PROTOBUF_SRC}) -target_link_libraries(mesos-protobufs PUBLIC protobuf) +target_link_libraries(mesos-protobufs PUBLIC + protobuf + $<$<BOOL:${ENABLE_GRPC}>:grpc>) + target_include_directories( mesos-protobufs PUBLIC @@ -231,7 +237,13 @@ set(COMMON_SRC common/values.cpp) set(CSI_SRC - csi/paths.cpp) + csi/paths.cpp + csi/utils.cpp) + +if (ENABLE_GRPC) + list(APPEND CSI_SRC + csi/client.cpp) +endif () set(DOCKER_SRC docker/docker.cpp @@ -369,7 +381,15 @@ set(RESOURCE_PROVIDER_SRC resource_provider/manager.cpp resource_provider/registrar.cpp resource_provider/validation.cpp - resource_provider/storage/disk_profile_adaptor.cpp) + resource_provider/storage/disk_profile_adaptor.cpp + resource_provider/storage/disk_profile_utils.cpp) + +# NOTE: The storage local resource provider uses Unix domain sockets to talk to +# CSI plugins, thus it is currently not supported on Windows. +if (ENABLE_GRPC AND NOT WIN32) + list(APPEND RESOURCE_PROVIDER_SRC + resource_provider/storage/provider.cpp) +endif () set(SCHEDULER_SRC sched/sched.cpp @@ -381,9 +401,6 @@ set(SECRET_SRC set(STATE_SRC state/in_memory.cpp) -set(STATUS_UPDATE_MANAGER_SRC - status_update_manager/operation.cpp) - if (NOT WIN32) list(APPEND STATE_SRC state/leveldb.cpp @@ -391,6 +408,9 @@ if (NOT WIN32) state/zookeeper.cpp) endif () +set(STATUS_UPDATE_MANAGER_SRC + status_update_manager/operation.cpp) + set(URI_SRC uri/fetcher.cpp uri/utils.cpp @@ -543,6 +563,7 @@ add_subdirectory(local) add_subdirectory(log) add_subdirectory(master) add_subdirectory(python/cli_new) +add_subdirectory(resource_provider/storage) add_subdirectory(slave) add_subdirectory(slave/containerizer/mesos) add_subdirectory(usage) http://git-wip-us.apache.org/repos/asf/mesos/blob/12a907bf/src/examples/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index e85eed6..6a6ee7c 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -52,6 +52,11 @@ if (NOT WIN32) add_executable(test-http-framework test_http_framework.cpp) add_executable(test-csi-user-framework test_csi_user_framework.cpp) + # TODO(chhsiao): The test CSI plugin is Linux only for now. + if (ENABLE_GRPC AND LINUX) + add_executable(test-csi-plugin test_csi_plugin.cpp) + endif () + # NOTE: Do not replace this with `link_libraries()`. While it may result in # less code, it is deprecated and relies on side effects instead of # explicitness. @@ -84,4 +89,11 @@ if (NOT WIN32) target_link_libraries(test-http-executor PRIVATE mesos) target_link_libraries(test-http-framework PRIVATE mesos) target_link_libraries(test-csi-user-framework PRIVATE mesos) + + # TODO(chhsiao): The test CSI plugin is Linux only for now. + if (ENABLE_GRPC AND LINUX) + # NOTE: We explicitly add `grpc` here since the test CSI plugin uses the + # server-side gRPC library, which might not be linked in mesos. + target_link_libraries(test-csi-plugin PRIVATE mesos grpc) + endif () endif () http://git-wip-us.apache.org/repos/asf/mesos/blob/12a907bf/src/resource_provider/storage/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/resource_provider/storage/CMakeLists.txt b/src/resource_provider/storage/CMakeLists.txt new file mode 100644 index 0000000..90fdd61 --- /dev/null +++ b/src/resource_provider/storage/CMakeLists.txt @@ -0,0 +1,21 @@ +# 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. + +# THE URI DISK PROFILE ADAPTOR LIBRARY. +####################################### +# NOTE: This library uses underscores to be consistent with other modules. +add_library(uri_disk_profile_adaptor uri_disk_profile_adaptor.cpp) +target_link_libraries(uri_disk_profile_adaptor PRIVATE mesos) http://git-wip-us.apache.org/repos/asf/mesos/blob/12a907bf/src/tests/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index ade5180..4eb8e23 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -70,6 +70,12 @@ if (LINUX) containerizer/setns_test_helper.cpp) endif () +if (ENABLE_GRPC) + list(APPEND MESOS_TESTS_UTILS_SRC + csi_client_tests.cpp + mock_csi_plugin.cpp) +endif () + # All the test sources. ####################### @@ -156,6 +162,7 @@ list(APPEND MESOS_TESTS_SRC if (NOT WIN32) list(APPEND MESOS_TESTS_SRC container_logger_tests.cpp + disk_profile_adaptor_tests.cpp disk_quota_tests.cpp dynamic_weights_tests.cpp examples_tests.cpp @@ -228,20 +235,30 @@ if (LINUX) containerizer/volume_host_path_isolator_tests.cpp containerizer/volume_image_isolator_tests.cpp containerizer/volume_secret_isolator_tests.cpp) + + if (ENABLE_GRPC) + list(APPEND MESOS_TESTS_SRC + agent_resource_provider_config_api_tests.cpp + storage_local_resource_provider_tests.cpp) + endif () endif () # THE TEST AND HELPER EXECUTABLES. ################################## add_library(mesos-tests-interface INTERFACE) -target_link_libraries(mesos-tests-interface INTERFACE mesos googletest) +target_link_libraries( + mesos-tests-interface INTERFACE + mesos + googletest) if (NOT WIN32) target_link_libraries( mesos-tests-interface INTERFACE load_qos_controller fixed_resource_estimator - logrotate_container_logger) + logrotate_container_logger + uri_disk_profile_adaptor) endif () target_compile_definitions( @@ -313,8 +330,16 @@ if (NOT WIN32) persistent-volume-framework test-executor test-framework + test-csi-user-framework test-http-executor test-http-framework) + + # SLRP-related tests are Linux only and require the test CSI plugin binary. + if (ENABLE_GRPC AND LINUX) + add_dependencies( + mesos-tests + test-csi-plugin) + endif () endif ()