diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8364c9e --- /dev/null +++ b/.gitignore @@ -0,0 +1,49 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# CMake +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +bin/ +configuration/ +volumes/ +containers/config/htpasswd diff --git a/benchmarks/warm_benchmark.cpp b/benchmarks/warm_benchmark.cpp index e19bbd5..aeaa3b4 100644 --- a/benchmarks/warm_benchmark.cpp +++ b/benchmarks/warm_benchmark.cpp @@ -33,9 +33,11 @@ int main(int argc, char ** argv) rfaas::devices::deserialize(in_dev); in_dev.close(); + #ifdef USE_GNI_AUTH rdmalib::Configuration::get_instance().configure_cookie( rfaas::devices::instance()._configuration.authentication_credential ); + #endif // Read benchmark settings std::ifstream benchmark_cfg{opts.json_config}; diff --git a/config/executor_manager.json b/config/executor_manager.json index bbb1b86..ac798d7 100644 --- a/config/executor_manager.json +++ b/config/executor_manager.json @@ -1,13 +1,13 @@ { "config": { "rdma_device": "", - "rdma_device_port": , + "rdma_device_port": 10004, "resource_manager_address": "", "resource_manager_port": 0, "resource_manager_secret": 0 }, "executor": { - "sandbox-type": "process", + "sandbox_type": "process", "repetitions": 100, "warmup_iters": 0, "pin_threads": false @@ -16,30 +16,57 @@ { "key": "sarus", "value": { - "devices": [ - "/dev/kgni0", "dev/kdreg" - ], - "mounts": [ - "/opt/cray", - "/tmp/drcc.sock", - "/etc/opt/cray/rdma-credentials", - "/etc/alternatives/cray-ugni", - "/etc/alternatives/cray-xpmem", - "/etc/alternatives/cray-alps", - "/etc/alternatives/cray-udreg", - "/etc/alternatives/cray-wlm_detect" - ], - "mount_filesystem": [ - "/scratch/snx3000/{user}" - ], - "env": [ - { - "key": "LD_LIBRARY_PATH", - "value": "/opt/cray/xpmem/default/lib64/;/opt/cray/udreg/default/lib64;/opt/cray/alps/default/lib64;/opt/cray/wlm_detect/default/lib64/" - } - ] + "index": 1, + "data": { + "user": "mcopik", + "name": "spcleth/hpc-disagg:rfaas-executor-daint", + "devices": [ + "/dev/kgni0", "dev/kdreg" + ], + "mounts": [ + "/opt/cray", + "/tmp/drcc.sock", + "/etc/opt/cray/rdma-credentials", + "/etc/alternatives/cray-ugni", + "/etc/alternatives/cray-xpmem", + "/etc/alternatives/cray-alps", + "/etc/alternatives/cray-udreg", + "/etc/alternatives/cray-wlm_detect" + ], + "mount_filesystem": [ + "/scratch/snx3000/{user}" + ], + "env": [ + { + "key": "LD_LIBRARY_PATH", + "value": "/opt/cray/xpmem/default/lib64/;/opt/cray/udreg/default/lib64;/opt/cray/alps/default/lib64;/opt/cray/wlm_detect/default/lib64/" + } + ] + } + } + }, + { + "key": "docker", + "value": { + "index": 0, + "data": { + "image": "rfaas-registry/rfaas-base", + "network": "mynet", + "ip": "172.31.82.202", + "volume": "/home/ubuntu/rfaas/containers/opt", + "registry_ip": "172.31.82.200", + "registry_port": 5000 + } + } + }, + { + "key": "singularity", + "value": { + "index": 2, + "data": { + "container": "rfaas-container-singularity" + } } } ] } - diff --git a/config/executor_manager_backup.json b/config/executor_manager_backup.json new file mode 100644 index 0000000..1f7285b --- /dev/null +++ b/config/executor_manager_backup.json @@ -0,0 +1,63 @@ +{ + "config": { + "rdma_device": "", + "rdma_device_port": , + "resource_manager_address": "", + "resource_manager_port": 0, + "resource_manager_secret": 0 + }, + "executor": { + "sandbox-type": "process", + "repetitions": 100, + "warmup_iters": 0, + "pin_threads": false + }, + "sandbox-configuration": { + "sandboxes": [ + { + "key": "sarus", + "value": { + "user": "mcopik", + "name": "spcleth/hpc-disagg:rfaas-executor-daint", + "devices": [ + "/dev/kgni0", "dev/kdreg" + ], + "mounts": [ + "/opt/cray", + "/tmp/drcc.sock", + "/etc/opt/cray/rdma-credentials", + "/etc/alternatives/cray-ugni", + "/etc/alternatives/cray-xpmem", + "/etc/alternatives/cray-alps", + "/etc/alternatives/cray-udreg", + "/etc/alternatives/cray-wlm_detect" + ], + "mount_filesystem": [ + "/scratch/snx3000/{user}" + ], + "env": [ + { + "key": "LD_LIBRARY_PATH", + "value": "/opt/cray/xpmem/default/lib64/;/opt/cray/udreg/default/lib64;/opt/cray/alps/default/lib64;/opt/cray/wlm_detect/default/lib64/" + } + ] + } + }, + { + "key": "docker", + "value": { + "devices": [ + "dev1", "dev2" + ], + "image": "rfaas-registry/rfaas-base", + "network": "mynet", + "ip": "172.31.82.202", + "volume": "/home/ubuntu/rfaas/containers/opt", + "registry_ip": "172.31.82.200", + "registry_port": 5000 + } + } + ] + } +} + diff --git a/containers/build_base.sh b/containers/build_base.sh new file mode 100755 index 0000000..2b2657a --- /dev/null +++ b/containers/build_base.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -t rfaas-base:latest - < rfaas-base.Dockerfile diff --git a/containers/init_docker.sh b/containers/init_docker.sh new file mode 100755 index 0000000..c976dae --- /dev/null +++ b/containers/init_docker.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# This script builds the rfaas-base docker container, pushes it to the +# registry, sets up a docker volume, and generates example configuration +# json which should then be updated in config/executor_manager.json. +# The script also configures a docker network for suitable use with +# docker_rdma_sriov + +# NOTE: Run this script from repo root, and make sure the sriov docker plugin +# is installed + +set -e + +if [ $# -lt 2 ]; then + echo "usage: ./init_docker.sh [ ]" + exit +fi + +REG_IP=$1 # IP or name of the docker registry +REG_PORT=$2 # Port of the docker registry +NET_MODE=$3 # Docker networking mode -- sriov or host +DEVICE=$4 # The RDMA adapter to use for networking +SUBNET=$5 # Subnet for the docker network + +IMG_NAME=rfaas-base +REG_IMG=$REG_IP:$REG_PORT/$IMG_NAME + +# Build the docker container, login and push to the registry +docker build -t $IMG_NAME - < containers/rfaas-base.Dockerfile +echo "built rfaas-base image" +docker login $REG_IP:$REG_PORT +echo "logged into docker daemon" + +if docker push $REG_IMG; then + echo "ERROR: make sure a docker registry is actually running on $REG_IP:$REG_PORT. + Start one with scripts/run_registry.sh" + exit +else + echo "pushed rfaas-base image to $REG_IMG" +fi + +# Set up docker network +net_name=testnet +if ["$NET_MODE" = "sriov"]; then + docker network create -d sriov --subnet=$SUBNET -o netdevice=$DEVICE $net_name +elif ["$NET_MODE" = "host"]; then + net_name="host" +else + echo "ERROR: invalid networking mode $NET_MODE. Valid options are sriov and host." + exit +fi +echo "set up docker network" + +# Configure volume +volume=$(pwd)/volumes/rfaas-test/opt # Do not put a trailing slash +mkdir -p $volume/bin +cp bin/executor $volume/bin +cp examples/libfunctions.so $volume + +# Print json to be updated +config=$(jq -n --arg use_docker "true" \ + --arg image "$REG_IMG" \ + --arg network "$net_name" \ + --arg ip "" \ + --arg volume $volume \ + --arg registry_ip "$REG_IP" \ + --arg registry_port "$REG_PORT" \ + '{ + "image": $image, + "network": $network, + "ip": $ip, + "volume": $volume, + "registry_ip": $registry_ip, + "registry_port": $registry_port + }' +) + +echo "Update config/executor_manager.json with" +echo "$config" + diff --git a/containers/rfaas-base.Dockerfile b/containers/rfaas-base.Dockerfile new file mode 100644 index 0000000..401297e --- /dev/null +++ b/containers/rfaas-base.Dockerfile @@ -0,0 +1,14 @@ +# Container version should be same ubuntu version as where `executor` +# was built (due to glibc versioning) + +FROM ubuntu:22.04 + +#ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install -y \ + libibverbs-dev librdmacm-dev + +RUN mkdir -p /opt/bin +WORKDIR "/opt/bin" + diff --git a/rdmalib/include/rdmalib/buffer.hpp b/rdmalib/include/rdmalib/buffer.hpp index f821757..1d3a032 100644 --- a/rdmalib/include/rdmalib/buffer.hpp +++ b/rdmalib/include/rdmalib/buffer.hpp @@ -61,10 +61,11 @@ namespace rdmalib { #endif #ifdef USE_LIBFABRIC void *lkey() const; + uint64_t rkey() const; #else uint32_t lkey() const; + uint32_t rkey() const; #endif - uint64_t rkey() const; ScatterGatherElement sge(uint32_t size, uint32_t offset) const; }; @@ -79,6 +80,12 @@ namespace rdmalib { // When accessing the remote buffer, we might not need to know the size. RemoteBuffer(uintptr_t addr, uint64_t rkey, uint32_t size = 0); + #ifdef USE_LIBFABRIC + RemoteBuffer(uintptr_t addr, uint64_t rkey, uint32_t size); + #else + RemoteBuffer(uintptr_t addr, uint32_t rkey, uint32_t size); + #endif + template void serialize(Archive & ar) { diff --git a/rdmalib/include/rdmalib/rdmalib.hpp b/rdmalib/include/rdmalib/rdmalib.hpp index c8ba193..2a44e66 100644 --- a/rdmalib/include/rdmalib/rdmalib.hpp +++ b/rdmalib/include/rdmalib/rdmalib.hpp @@ -25,6 +25,7 @@ extern "C" { #include #include +#include namespace rdmalib { @@ -45,7 +46,9 @@ namespace rdmalib { ~Configuration(); std::once_flag _access_flag; + #ifdef USE_GNI_AUTH drc_info_handle_t _credential_info; + #endif uint64_t _cookie; uint32_t _credential; bool _is_configured; diff --git a/rdmalib/lib/buffer.cpp b/rdmalib/lib/buffer.cpp index 1db48ed..0bacdaf 100644 --- a/rdmalib/lib/buffer.cpp +++ b/rdmalib/lib/buffer.cpp @@ -247,6 +247,12 @@ namespace rdmalib { size(0) {} + RemoteBuffer::RemoteBuffer(uintptr_t addr, uint64_t rkey, uint32_t size): + addr(addr), + rkey(rkey), + size(size) + {} + #ifdef USE_LIBFABRIC RemoteBuffer::RemoteBuffer(uintptr_t addr, uint64_t rkey, uint32_t size): addr(addr), diff --git a/rdmalib/lib/rdmalib.cpp b/rdmalib/lib/rdmalib.cpp index fe8864d..ef2776d 100644 --- a/rdmalib/lib/rdmalib.cpp +++ b/rdmalib/lib/rdmalib.cpp @@ -57,6 +57,8 @@ namespace rdmalib { return _instance; } + #ifdef USE_GNI_AUTH + void Configuration::configure_cookie(uint32_t credential) { Configuration& inst = _get_instance(); @@ -87,6 +89,7 @@ namespace rdmalib { { return _is_configured; } + #endif Configuration Configuration::_instance; @@ -136,7 +139,10 @@ namespace rdmalib { impl::expect_zero(rdma_getaddrinfo(ip.c_str(), std::to_string(port).c_str(), &hints, &addrinfo)); #endif this->_port = port; + + #ifdef USE_LIBFABRIC this->_ip = ip; + #endif } Address::Address(const std::string & sip, const std::string & dip, int port) diff --git a/scripts/push_image.sh b/scripts/push_image.sh new file mode 100755 index 0000000..40beeb3 --- /dev/null +++ b/scripts/push_image.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Push an image to the local docker registry + +if [ $# -lt 3 ]; then + echo "usage: ./push_image.sh "; + exit +fi + +IMAGE=$1 +IP=$2 +PORT=$3 +docker push $IP:$PORT/$IMAGE diff --git a/scripts/registry.yaml b/scripts/registry.yaml new file mode 100644 index 0000000..3ed7a10 --- /dev/null +++ b/scripts/registry.yaml @@ -0,0 +1,20 @@ +version: "3" + +services: + registry: + image: registry:2 + container_name: rfaas-registry + ports: + - "5000:5000" + environment: + REGISTRY_AUTH: htpasswd + REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd + REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm + REGISTRY_STORAGE_DELETE_ENABLED: "true" + #REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt + #REGISTRY_HTTP_TLS_KEY: /certs/domain.unencrypted.key + #REGISTRY_HTTP_SECRET: supersecrettext + volumes: + - /home/ubuntu/rfaas/containers/registry:/var/lib/registry + - /home/ubuntu/rfaas/containers/config:/auth + #- /home/ubuntu/rfaas/containers/config/certs:/certs diff --git a/scripts/run_registry.sh b/scripts/run_registry.sh new file mode 100755 index 0000000..d3cb0eb --- /dev/null +++ b/scripts/run_registry.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Run this script on the server where you want the docker registry to be hosted +# Recommended to host the registry on the same server as the executor manager + +# NOTE: Run this script from the repo root + +PORT=5000 +NAME="rfaas-registry" + +set -e + +# Make password file if it doesn't already exist +cfg=containers/config +mkdir -p $cfg +if [ -s $cfg/htpasswd ]; then + echo "htpasswd exists" +else + sudo htpasswd -Bc $cfg/htpasswd $USER + echo "created htpasswd file" +fi + +# Generate certs to use TLS (if they dont already exist) +## if [ -s $cfg/certs/domain.key ]; then +## echo "using certs in $cfg/certs" +## else +## mkdir -p $cfg/certs +## openssl genpkey -algorithm RSA -out $cfg/certs/domain.key -aes256 +## +## openssl req -new \ +## -key $cfg/certs/domain.key \ +## -out $cfg/certs/domain.csr \ +## -addext 'subjectAltName = IP:172.31.82.200' +## +## openssl x509 -req -days 365 \ +## -in $cfg/certs/domain.csr \ +## -signkey $cfg/certs/domain.key \ +## -out $cfg/certs/domain.crt +## +## openssl rsa -in $cfg/certs/domain.key -out $cfg/certs/domain.unencrypted.key +## echo "generated certs in $cfg/certs" +## fi + +# Start registry +sudo docker-compose -f scripts/registry.yaml up -d +echo "started docker registry $NAME on port $PORT" + diff --git a/server/executor/cli.cpp b/server/executor/cli.cpp index a5f9f9f..fbaf53f 100644 --- a/server/executor/cli.cpp +++ b/server/executor/cli.cpp @@ -36,6 +36,8 @@ int main(int argc, char ** argv) opts.func_size, opts.msg_size, opts.recv_buffer_size, opts.max_inline_data, opts.timeout ); + + #ifdef USE_GNI_AUTH spdlog::info( "My manager runs at {}:{}, its secret is {}, the accounting buffer is at {} with rkey {}, cookie {}", opts.mgr_address, opts.mgr_port, opts.mgr_secret, @@ -46,6 +48,13 @@ int main(int argc, char ** argv) rdmalib::Configuration::get_instance().configure_cookie( opts.authentication_cookie ); + #else + spdlog::info( + "My manager runs at {}:{}, its secret is {}, the accounting buffer is at {} with rkey {}", + opts.mgr_address, opts.mgr_port, opts.mgr_secret, + opts.accounting_buffer_addr, opts.accounting_buffer_rkey + ); + #endif executor::ManagerConnection mgr{ opts.mgr_address, diff --git a/server/executor_manager/cli.cpp b/server/executor_manager/cli.cpp index d86073b..626c5a5 100644 --- a/server/executor_manager/cli.cpp +++ b/server/executor_manager/cli.cpp @@ -52,9 +52,11 @@ int main(int argc, char ** argv) std::ifstream in_dev{opts.device_database}; rfaas::devices::deserialize(in_dev); + #ifdef USE_GNI_AUTH rdmalib::Configuration::get_instance().configure_cookie( rfaas::devices::instance()._configuration.authentication_credential ); + #endif // Read executor manager settings std::ifstream in_cfg{opts.json_config}; diff --git a/server/executor_manager/executor_process.cpp b/server/executor_manager/executor_process.cpp index 8e0bf57..f9f5f1f 100644 --- a/server/executor_manager/executor_process.cpp +++ b/server/executor_manager/executor_process.cpp @@ -139,13 +139,15 @@ namespace rfaas::executor_manager { "sarus", "run" }; - exec.sandbox_config->generate_args(argv, exec.sandbox_user); + SarusConfiguration config = std::get(*exec.sandbox_config); + config.generate_args(argv, exec.sandbox_user); argv.emplace_back(exec.sandbox_name); - argv.emplace_back(exec.sandbox_config->get_executor_path()); + argv.emplace_back(config.get_executor_path()); additional_args = { + "/opt/bin/executor", "-a", client_addr.c_str(), "-p", client_port.c_str(), "--polling-mgr", "thread", @@ -170,46 +172,13 @@ namespace rfaas::executor_manager { }; } else if(sandbox_type == SandboxType::DOCKER) { - //const char * argv[] = { - // "docker_rdma_sriov", "run", - // "--rm", - // "--net=mynet", "-i", //"-it", - // // FIXME: make configurable - // "--ip=148.187.105.220", - // // FIXME: make configurable - // "--volume", "/users/mcopik/projects/rdma/repo/build_repo2:/opt", - // // FIXME: make configurable - // "rdma-test", - // "/opt/bin/executor", - // "-a", client_addr.c_str(), - // "-p", client_port.c_str(), - // "--polling-mgr", "thread", - // "-r", executor_repetitions.c_str(), - // "-x", executor_recv_buf.c_str(), - // "-s", client_in_size.c_str(), - // "--pin-threads", "true", - // "--fast", client_cores.c_str(), - // "--warmup-iters", executor_warmups.c_str(), - // "--max-inline-data", executor_max_inline.c_str(), - // "--func-size", client_func_size.c_str(), - // "--timeout", client_timeout.c_str(), - // "--mgr-address", conn.addr.c_str(), - // "--mgr-port", mgr_port.c_str(), - // "--mgr-secret", mgr_secret.c_str(), - // "--mgr-buf-addr", mgr_buf_addr.c_str(), - // "--mgr-buf-rkey", mgr_buf_rkey.c_str(), - // nullptr - //}; argv = { - "docker_rdma_sriov", "run", - "--rm", - "--net=mynet", "-i", //"-it", - // FIXME: make configurable - "--ip=148.187.105.250", - // FIXME: make configurable - "--volume", "/users/mcopik/projects/rdma/repo/build_repo2:/opt", - // FIXME: make configurable - "rdma-test", + "docker_rdma_sriov", "run", "--rm", "-i" + }; + DockerConfiguration config = std::get(*exec.sandbox_config); + config.generate_args(argv); + + additional_args = { "/opt/bin/executor", "-a", client_addr.c_str(), "-p", client_port.c_str(), @@ -228,8 +197,15 @@ namespace rfaas::executor_manager { "--mgr-secret", mgr_secret.c_str(), "--mgr-buf-addr", mgr_buf_addr.c_str(), "--mgr-buf-rkey", mgr_buf_rkey.c_str(), + #ifdef USE_GNI_AUTH + "--authentication-cookie", authentication_cookie.c_str(), + #endif nullptr }; + + } else if(sandbox_type == SandboxType::SINGULARITY) { + // Handle Singularity case + SingularityConfiguration config = std::get(*exec.sandbox_config); } std::vector cstrings_argv; @@ -243,7 +219,8 @@ namespace rfaas::executor_manager { SPDLOG_DEBUG("Executor launch arguments"); for(const char* str : cstrings_argv) if(str) - SPDLOG_DEBUG(str); + std::cout<(&cstrings_argv.data()[0])); if(ret == -1) { diff --git a/server/executor_manager/settings.cpp b/server/executor_manager/settings.cpp index 90c02ca..bd7d640 100644 --- a/server/executor_manager/settings.cpp +++ b/server/executor_manager/settings.cpp @@ -15,7 +15,8 @@ namespace rfaas::executor_manager { static std::map sandboxes = { {"process", SandboxType::PROCESS}, {"docker", SandboxType::DOCKER}, - {"sarus", SandboxType::SARUS} + {"sarus", SandboxType::SARUS}, + {"singularity", SandboxType::SINGULARITY} }; return sandboxes.at(type); } @@ -25,7 +26,8 @@ namespace rfaas::executor_manager { static std::map sandboxes = { {SandboxType::PROCESS, "process"}, {SandboxType::DOCKER, "docker"}, - {SandboxType::SARUS, "sarus"} + {SandboxType::SARUS, "sarus"}, + {SandboxType::SINGULARITY, "singularity"} }; return sandboxes.at(type); } @@ -50,17 +52,22 @@ namespace rfaas::executor_manager { settings.exec.max_inline_data = dev->max_inline_data; settings.exec.recv_buffer_size = dev->default_receive_buffer_size; - settings.exec.sandbox_config = &settings.sandboxes.at(settings.exec.sandbox_type); + if (settings.exec.sandbox_type != SandboxType::PROCESS) { + settings.exec.sandbox_config = &settings.sandboxes.at(settings.exec.sandbox_type); + } // FIXME: should be sent with request - settings.exec.sandbox_user = "mcopik"; - settings.exec.sandbox_name = "spcleth/hpc-disagg:rfaas-executor-daint"; - for(auto & mount : settings.exec.sandbox_config->mounts) - std::cerr << mount << std::endl; + if (settings.exec.sandbox_type == SandboxType::SARUS) { + SarusConfiguration config = std::get(*settings.exec.sandbox_config); + settings.exec.sandbox_user = config.user; + settings.exec.sandbox_name = config.name; + for(auto & mount : config.mounts) + std::cerr << mount << std::endl; + } return settings; } - void SandboxConfiguration::generate_args(std::vector & args, const std::string & user) const + void SarusConfiguration::generate_args(std::vector & args, const std::string & user) const { for(auto & dev : this->devices) args.emplace_back(rdmalib::impl::string_format("--device=%s", dev)); @@ -81,7 +88,7 @@ namespace rfaas::executor_manager { } - std::string SandboxConfiguration::get_executor_path() const + std::string SarusConfiguration::get_executor_path() const { // Horrible hack - we need to get the location of the executor. // We assume that rFaaS is built on the shared filesystem that is mounted @@ -95,5 +102,18 @@ namespace rfaas::executor_manager { return path / "executor"; } + void DockerConfiguration::generate_args(std::vector & args) const { + std::string ip_arg = "--ip=" + ip; + std::string volume_arg = volume + ":/opt"; + std::string net_arg = "--net=" + network; + std::string registry_port = std::to_string(this->registry_port); + std::string docker_image = registry_ip + ":" + registry_port + "/" + image; + + args.emplace_back(net_arg); + args.emplace_back(ip_arg); + args.emplace_back("--volume"); + args.emplace_back(volume_arg); + args.emplace_back(docker_image); + } } diff --git a/server/executor_manager/settings.hpp b/server/executor_manager/settings.hpp index 72cbbac..ec95f20 100644 --- a/server/executor_manager/settings.hpp +++ b/server/executor_manager/settings.hpp @@ -11,13 +11,16 @@ #include #include #include +#include +#include namespace rfaas::executor_manager { enum class SandboxType { PROCESS = 0, DOCKER = 1, - SARUS = 2 + SARUS = 2, + SINGULARITY = 3, }; SandboxType sandbox_deserialize(std::string type); @@ -28,17 +31,40 @@ namespace rfaas::executor_manager { namespace rfaas::executor_manager { - struct SandboxConfiguration - { + struct DockerConfiguration { + std::string image; + std::string network; + std::string ip; + std::string volume; + std::string registry_ip; + int registry_port; + + template + void load(Archive & ar) + { + ar( + CEREAL_NVP(image), CEREAL_NVP(network), + CEREAL_NVP(ip), CEREAL_NVP(volume), + CEREAL_NVP(registry_ip), CEREAL_NVP(registry_port) + ); + } + + void generate_args(std::vector & args) const; + }; + + struct SarusConfiguration { + std::string user; + std::string name; std::vector devices; std::vector mounts; std::vector mount_filesystem; std::map env; template - void load(Archive & ar ) + void load(Archive & ar) { ar( + CEREAL_NVP(user), CEREAL_NVP(name), CEREAL_NVP(devices), CEREAL_NVP(mounts), CEREAL_NVP(mount_filesystem), CEREAL_NVP(env) ); @@ -53,8 +79,25 @@ namespace rfaas::executor_manager { * this way. **/ std::string get_executor_path() const; + + }; + + struct SingularityConfiguration { + // TODO: Add other singularity options here + std::string container; + + template + void load(Archive & ar) + { + ar( + CEREAL_NVP(container) + ); + } }; + using SandboxConfiguration = std::variant; + struct ExecutorSettings { SandboxType sandbox_type;