From ca3a9a88bdba65a99590b847e61e40bf471826be Mon Sep 17 00:00:00 2001 From: Chamberlain Date: Tue, 16 Dec 2025 15:26:34 +0800 Subject: [PATCH] =?UTF-8?q?ID:issue00=20Reason:=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=88=86=E5=B8=83=E5=BC=8F=E8=9E=8D=E5=90=88=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flags/function_agent_flags.cpp | 2 ++ .../flags/function_agent_flags.h | 6 ++++++ functionsystem/src/function_agent/main.cpp | 1 + .../instance_proxy/request_dispatcher.cpp | 1 + .../instance_control/instance_ctrl_actor.cpp | 1 + .../src/runtime_manager/config/build.cpp | 2 ++ .../src/runtime_manager/config/flags.cpp | 2 ++ .../src/runtime_manager/config/flags.h | 6 ++++++ .../src/runtime_manager/executor/executor.cpp | 1 + .../src/runtime_manager/executor/executor.h | 1 + .../executor/runtime_executor.cpp | 14 +++++++++++--- .../executor/runtime_executor_test.cpp | 19 +++++++++++++++++-- scripts/deploy/function_system/install.sh | 1 + 13 files changed, 52 insertions(+), 5 deletions(-) diff --git a/functionsystem/src/function_agent/flags/function_agent_flags.cpp b/functionsystem/src/function_agent/flags/function_agent_flags.cpp index ca85194..8680706 100644 --- a/functionsystem/src/function_agent/flags/function_agent_flags.cpp +++ b/functionsystem/src/function_agent/flags/function_agent_flags.cpp @@ -71,6 +71,8 @@ FunctionAgentFlags::FunctionAgentFlags() false); AddFlag(&FunctionAgentFlags::codeAgingTime_, "code_aging_time", "code aging time", 0, NumCheck(0, MAX_CODE_AGING_TIME)); + AddFlag(&FunctionAgentFlags::enableDisConvCallStack, "enable_dis_conv_call_stack", + "enable distributed convergent call stack", false); } FunctionAgentFlags::~FunctionAgentFlags() = default; diff --git a/functionsystem/src/function_agent/flags/function_agent_flags.h b/functionsystem/src/function_agent/flags/function_agent_flags.h index 16acf97..8a70d04 100644 --- a/functionsystem/src/function_agent/flags/function_agent_flags.h +++ b/functionsystem/src/function_agent/flags/function_agent_flags.h @@ -129,6 +129,11 @@ const std::string &GetAccessKey() const return agentUID; } + const bool &GetEnableDisConvCallStack() const + { + return enableDisConvCallStack; + } + const bool &GetEnableSignatureValidation() const { return enableSignatureValidation_; @@ -158,6 +163,7 @@ protected: std::string decryptAlgorithm; bool enableMergeProcess = false; + bool enableDisConvCallStack = false; std::string agentUID = ""; bool enableSignatureValidation_ = false; }; diff --git a/functionsystem/src/function_agent/main.cpp b/functionsystem/src/function_agent/main.cpp index a3d0153..0caaaae 100644 --- a/functionsystem/src/function_agent/main.cpp +++ b/functionsystem/src/function_agent/main.cpp @@ -272,6 +272,7 @@ int main(int argc, char **argv) return EXIT_ABNORMAL; } + YRLOG_DEBUG("function_agent GetEnableDisConvCallStack = {}", flags.GetEnableDisConvCallStack()); if (!g_functionAgentSwitcher->InitLiteBus(address, flags.GetLitebusThreadNum())) { g_functionAgentSwitcher->SetStop(); } else { diff --git a/functionsystem/src/function_proxy/busproxy/instance_proxy/request_dispatcher.cpp b/functionsystem/src/function_proxy/busproxy/instance_proxy/request_dispatcher.cpp index d5c9acb..391736a 100644 --- a/functionsystem/src/function_proxy/busproxy/instance_proxy/request_dispatcher.cpp +++ b/functionsystem/src/function_proxy/busproxy/instance_proxy/request_dispatcher.cpp @@ -50,6 +50,7 @@ runtime::NotifyRequest CallResultToNotifyRequest(const SharedStreamMsg &request) notifyRequest.set_code(Status::GetPosixErrorCode(callresult->code())); notifyRequest.set_requestid(callresult->requestid()); notifyRequest.mutable_smallobjects()->Swap(callresult->mutable_smallobjects()); + notifyRequest.mutable_stacktraceinfos()->Swap(callresult->mutable_stacktraceinfos()); if (callresult->has_runtimeinfo()) { notifyRequest.mutable_runtimeinfo()->Swap(callresult->mutable_runtimeinfo()); } diff --git a/functionsystem/src/function_proxy/local_scheduler/instance_control/instance_ctrl_actor.cpp b/functionsystem/src/function_proxy/local_scheduler/instance_control/instance_ctrl_actor.cpp index a91e76e..b82bc34 100644 --- a/functionsystem/src/function_proxy/local_scheduler/instance_control/instance_ctrl_actor.cpp +++ b/functionsystem/src/function_proxy/local_scheduler/instance_control/instance_ctrl_actor.cpp @@ -2571,6 +2571,7 @@ litebus::Future InstanceCtrlActor::SendNotifyResult( notifyRequest.set_code(Status::GetPosixErrorCode(callResult->code())); notifyRequest.set_message(callResult->message()); notifyRequest.mutable_smallobjects()->Swap(callResult->mutable_smallobjects()); + notifyRequest.mutable_stacktraceinfos()->Swap(callResult->mutable_stacktraceinfos()); if (callResult->has_runtimeinfo()) { notifyRequest.mutable_runtimeinfo()->Swap(callResult->mutable_runtimeinfo()); } diff --git a/functionsystem/src/runtime_manager/config/build.cpp b/functionsystem/src/runtime_manager/config/build.cpp index bddc43d..9a2f345 100644 --- a/functionsystem/src/runtime_manager/config/build.cpp +++ b/functionsystem/src/runtime_manager/config/build.cpp @@ -59,6 +59,7 @@ const static std::string DERICT_RUNTIME_SERVER_PORT = "DERICT_RUNTIME_SERVER_POR const static std::string ENABLE_TRACE = "ENABLE_TRACE"; const static std::string TRACE_CONFIG = "TRACE_CONFIG"; const static std::string RUNTIME_TRACE_CONFIG = "RUNTIME_TRACE_CONFIG"; +const static std::string ENABLE_DIS_CONV_CALL_STACK = "ENABLE_DIS_CONV_CALL_STACK"; const static std::string S3_STORAGE_TYPE = "s3"; @@ -185,6 +186,7 @@ std::map GeneratePosixEnvs(const RuntimeConfig &config config.proxyIP + ":" + config.proxyGrpcServerPort }, { CLUSTER_ID, config.clusterID }, { NODE_ID, config.nodeID }, + { ENABLE_DIS_CONV_CALL_STACK, config.enableDisConvCallStack ? "true" : "false" }, { YR_DEBUG_SERVER_PORT, debugServerPort } }; diff --git a/functionsystem/src/runtime_manager/config/flags.cpp b/functionsystem/src/runtime_manager/config/flags.cpp index 4d8e310..41ae9ae 100644 --- a/functionsystem/src/runtime_manager/config/flags.cpp +++ b/functionsystem/src/runtime_manager/config/flags.cpp @@ -181,5 +181,7 @@ Flags::Flags() AddFlag(&Flags::runtimeInstanceDebugEnable_, "runtime_instance_debug_enable", "runtime instance debug enable", false); AddFlag(&Flags::userLogExportMode_, "user_log_export_mode", "user log export mode: std/file", "file"); + AddFlag(&Flags::enableDisConvCallStack_, "enable_dis_conv_call_stack", "enable distributed convergent call stack", + false); } } // namespace functionsystem::runtime_manager diff --git a/functionsystem/src/runtime_manager/config/flags.h b/functionsystem/src/runtime_manager/config/flags.h index b892096..02985ce 100644 --- a/functionsystem/src/runtime_manager/config/flags.h +++ b/functionsystem/src/runtime_manager/config/flags.h @@ -252,6 +252,11 @@ public: return massifEnable_; } + bool GetEnableDisConvCallStack() const + { + return enableDisConvCallStack_; + } + bool GetInheritEnv() const { return inheritEnv_; @@ -454,6 +459,7 @@ protected: bool runtimeInstanceDebugEnable_{ false }; std::string userLogExportMode_; std::string diskResources_; + bool enableDisConvCallStack_ = false; }; } // namespace functionsystem::runtime_manager diff --git a/functionsystem/src/runtime_manager/executor/executor.cpp b/functionsystem/src/runtime_manager/executor/executor.cpp index 6e8d6d5..983adfb 100644 --- a/functionsystem/src/runtime_manager/executor/executor.cpp +++ b/functionsystem/src/runtime_manager/executor/executor.cpp @@ -145,6 +145,7 @@ void Executor::SetRuntimeConfig(const Flags &flags) YRLOG_DEBUG("prestart config is not empty, start to parse"); InitPrestartConfig(prestartConfig); } + config_.enableDisConvCallStack = flags.GetEnableDisConvCallStack(); config_.runtimeDirectConnectionEnable = flags.GetRuntimeDirectConnectionEnable(); config_.runtimeHomeDir = flags.GetRuntimeHomeDir(); config_.nodeJsEntryPath = flags.GetNodeJsEntryPath(); diff --git a/functionsystem/src/runtime_manager/executor/executor.h b/functionsystem/src/runtime_manager/executor/executor.h index 5529d4d..0ee8bc2 100644 --- a/functionsystem/src/runtime_manager/executor/executor.h +++ b/functionsystem/src/runtime_manager/executor/executor.h @@ -93,6 +93,7 @@ struct RuntimeConfig { std::string userLogExportMode; bool cleanStreamProducerEnable; int virtualEnvIdleTimeLimit; + bool enableDisConvCallStack; }; struct PrestartProcess { diff --git a/functionsystem/src/runtime_manager/executor/runtime_executor.cpp b/functionsystem/src/runtime_manager/executor/runtime_executor.cpp index e7568fc..0cf8e6d 100644 --- a/functionsystem/src/runtime_manager/executor/runtime_executor.cpp +++ b/functionsystem/src/runtime_manager/executor/runtime_executor.cpp @@ -59,6 +59,7 @@ const std::string YR_LOG_LEVEL = "YR_LOG_LEVEL"; const std::string PYTHON_PATH = "PYTHONPATH"; const std::string PATH = "PATH"; const std::string PYTHON_LOG_CONFIG_PATH = "PYTHON_LOG_CONFIG"; +const std::string ENABLE_DIS_CONV_CALL_STACK = "ENABLE_DIS_CONV_CALL_STACK"; const std::string BASH_PATH = "/bin/bash"; const std::string MAX_LOG_SIZE_MB_ENV = "YR_MAX_LOG_SIZE_MB"; const std::string MAX_LOG_FILE_NUM_ENV = "YR_MAX_LOG_FILE_NUM"; @@ -867,6 +868,8 @@ std::map RuntimeExecutor::CombineEnvs(const Envs &envs combineEnvs[PYTHON_LOG_CONFIG_PATH] = config_.pythonLogConfigPath; combineEnvs[MAX_LOG_SIZE_MB_ENV] = std::to_string(config_.runtimeMaxLogSize); combineEnvs[MAX_LOG_FILE_NUM_ENV] = std::to_string(config_.runtimeMaxLogFileNum); + // set distributed convergent call stack enable environment variable + combineEnvs[ENABLE_DIS_CONV_CALL_STACK] = config_.enableDisConvCallStack ? "true" : "false"; std::string pythonPath = config_.runtimePath; if (!config_.pythonDependencyPath.empty()) { (void)pythonPath.append(":" + config_.pythonDependencyPath); @@ -1767,9 +1770,14 @@ bool RuntimeExecutor::StartPrestartRuntimeByRuntimeID(const std::string &runtime YRLOG_ERROR("get build args failed, can not start runtime, runtimeID: {}", runtimeID); return false; } - Envs envs = { .posixEnvs = { { IS_PRESTART, PRESTART_FLAG }, { RUNTIME_DIR, config_.runtimePath } }, - .customResourceEnvs = {}, - .userEnvs = {} }; + Envs envs = { + .posixEnvs = { + {IS_PRESTART, PRESTART_FLAG}, {RUNTIME_DIR, config_.runtimePath}, + {ENABLE_DIS_CONV_CALL_STACK, config_.enableDisConvCallStack ? "true" : "false"} + }, + .customResourceEnvs = {}, + .userEnvs = {} + }; std::string tlsJson = "{}\n"; std::shared_ptr execPtr; for (int j = 0; j < RETRY_TIMES; j++) { diff --git a/functionsystem/tests/unit/runtime_manager/executor/runtime_executor_test.cpp b/functionsystem/tests/unit/runtime_manager/executor/runtime_executor_test.cpp index d034c4c..e0d322f 100644 --- a/functionsystem/tests/unit/runtime_manager/executor/runtime_executor_test.cpp +++ b/functionsystem/tests/unit/runtime_manager/executor/runtime_executor_test.cpp @@ -100,6 +100,19 @@ const std::string testCondaConfig = R"( )"; std::shared_ptr BuildStartInstanceRequest(const std::string &language); + +class MockRuntimeExecutor : public RuntimeExecutor { +public: + explicit MockRuntimeExecutor(const std::string &name, const litebus::AID &functionAgentAID) : RuntimeExecutor(name, functionAgentAID) + { + } + + void SetDisConvCallStack(bool enable) + { + config_.enableDisConvCallStack = enable; + } +}; + class RuntimeExecutorTest : public ::testing::Test { public: [[maybe_unused]] static void SetUpTestSuite() @@ -127,7 +140,7 @@ public: "> /tmp/layer/func/bucket-test-log1/yr-test-runtime-executor/funcObj"); mockAgent_ = std::make_shared(); litebus::Spawn(mockAgent_); - executor_ = std::make_shared("RuntimeExecutorTestActor", mockAgent_->GetAID()); + executor_ = std::make_shared("RuntimeExecutorTestActor", mockAgent_->GetAID()); litebus::Spawn(executor_); litebus::os::SetEnv("YR_BARE_MENTAL", "1"); @@ -175,7 +188,7 @@ public: } protected: - std::shared_ptr executor_; + std::shared_ptr executor_; std::shared_ptr mockAgent_; std::string env_; std::vector pidArray; @@ -250,6 +263,8 @@ TEST_F(RuntimeExecutorTest, StartInstanceTest) deployConfig->set_deploydir(testDeployDir); deployConfig->set_storagetype("s3"); + executor_->SetDisConvCallStack(true); + auto future = executor_->StartInstance(startRequest, {}); auto instanceResponse = future.Get(); int32_t resCode = instanceResponse.code(); diff --git a/scripts/deploy/function_system/install.sh b/scripts/deploy/function_system/install.sh index a05e626..1b075e7 100644 --- a/scripts/deploy/function_system/install.sh +++ b/scripts/deploy/function_system/install.sh @@ -360,6 +360,7 @@ function install_function_agent_and_runtime_manager_in_the_same_process() { --etcd_ssl_base_path=${ETCD_SSL_BASE_PATH} \ --runtime_default_config="${RUNTIME_DEFAULT_CONFIG}" \ --proc_metrics_memory="${MEM4COMP}" ${unique_proxy_option} \ + --enable_dis_conv_call_stack="${ENABLE_DIS_CONV_CALL_STACK}" \ --runtime_instance_debug_enable="${RUNTIME_INSTANCE_DEBUG_ENABLE}" ${user_lod_export_option} & FUNCTION_AGENT_PID="$!" log_info "succeed to start function agent and runtime manager, port=${FUNCTION_AGENT_PORT} pid=${FUNCTION_AGENT_PID}" -- Gitee