diff --git a/control-plane/include/praas/control-plane/worker.hpp b/control-plane/include/praas/control-plane/worker.hpp index ef6b42f..96f7a2c 100644 --- a/control-plane/include/praas/control-plane/worker.hpp +++ b/control-plane/include/praas/control-plane/worker.hpp @@ -64,7 +64,9 @@ namespace praas::control_plane::worker { void handle_invocation( HttpServer::request_t request, HttpServer::callback_t&& callback, const std::string& app_id, std::string function_name, std::chrono::high_resolution_clock::time_point start, - std::optional process_name + std::optional process_name, + std::optional vcpus, + std::optional memory ); //////////////////////////////////////////////////////////////////////////////// diff --git a/control-plane/src/backend.cpp b/control-plane/src/backend.cpp index fbb469a..0239237 100644 --- a/control-plane/src/backend.cpp +++ b/control-plane/src/backend.cpp @@ -265,11 +265,11 @@ namespace praas::control_plane::backend { req.SetNetworkInterfaceIds({eni_interface}); _ec2_client->DescribeNetworkInterfacesAsync( + req, [this](auto* ptr, auto res, auto outcome, auto& context) mutable { _callback_describe_eni(ptr, res, outcome, context); }, - nullptr, - req + nullptr ); } diff --git a/control-plane/src/downscaler.cpp b/control-plane/src/downscaler.cpp index f8a5ee6..992ab2e 100644 --- a/control-plane/src/downscaler.cpp +++ b/control-plane/src/downscaler.cpp @@ -76,7 +76,7 @@ namespace praas::control_plane::downscaler { auto lock = ptr->read_lock(); auto name = ptr->name(); - _process_list[name] = ProcessStats{std::move(ptr), now_timestamp}; + _process_list[name] = ProcessStats{std::move(ptr), static_cast(now_timestamp)}; } else { auto lock = ptr->read_lock(); diff --git a/control-plane/src/http.cpp b/control-plane/src/http.cpp index fc3d447..6cb266d 100644 --- a/control-plane/src/http.cpp +++ b/control-plane/src/http.cpp @@ -175,12 +175,17 @@ namespace praas::control_plane { ) { std::string pid = request->getParameter("process_name"); + std::string vcpus_str = request->getParameter("vcpus"); + std::string memory_str = request->getParameter("memory"); - _logger->info("Push new invocation request of {}", function_name); + _logger->info("Push new invocation request of {}, vcpus {}, memory {}", function_name, vcpus_str, memory_str); auto start = std::chrono::high_resolution_clock::now(); _workers.add_task( &worker::Workers::handle_invocation, request, std::move(callback), app_name, function_name, - start, !pid.empty() ? std::make_optional(pid) : std::nullopt + start, + !pid.empty() ? std::make_optional(pid) : std::nullopt, + !vcpus_str.empty() ? std::make_optional(vcpus_str) : std::nullopt, + !memory_str.empty() ? std::make_optional(memory_str) : std::nullopt ); } diff --git a/control-plane/src/worker.cpp b/control-plane/src/worker.cpp index 33053bc..538ac9a 100644 --- a/control-plane/src/worker.cpp +++ b/control-plane/src/worker.cpp @@ -22,7 +22,9 @@ namespace praas::control_plane::worker { void Workers::handle_invocation( HttpServer::request_t request, HttpServer::callback_t&& callback, const std::string& app_id, std::string function_name, std::chrono::high_resolution_clock::time_point start, - std::optional process_name + std::optional process_name, + std::optional vcpus, + std::optional memory ) { Resources::RWAccessor acc; @@ -91,7 +93,12 @@ namespace praas::control_plane::worker { // Get a process or allocate one. // FIXME: make resources configurable acc.get()->get_controlplane_process( - _backend, *_server, process::Resources{"1", "2048", ""}, + _backend, *_server, + process::Resources{ + !vcpus.has_value() ? "1024" : vcpus.value(), + !memory.has_value() ? "2048" : memory.value(), + "" + }, [start, function_name, request = std::move(request), callback = std::move(callback)]( process::ProcessPtr proc_ptr, const std::optional& error_msg ) mutable {