From d74007cbb39dda4e8fe99c35c081a732eff33f56 Mon Sep 17 00:00:00 2001 From: Saurav Prakash Date: Thu, 17 Oct 2024 14:24:59 -0700 Subject: [PATCH] fix spwaning process bug in automatic eden doctor run Summary: # problem `eden doctor` automatic run is failing with below error- ``` EI1015 00:18:55.202938 116940 EdenServer.cpp:2767] Running periodic eden doctor dry-run. E1015 00:18:55.203525 116940 SpawnedProcess.cpp:706] class std::system_error: CreateProcess("edenfsctl" "doctor" "--dry-run") failed with cwd: (no cwd provided), creation flags: 0, execPath: (no execPath provided): Error (0x57) The parameter is incorrect. ``` # solution This is similar to D59783277. We need to pass SpawnedProcess options while spawning a process with default params. Reviewed By: genevievehelsel Differential Revision: D64432742 fbshipit-source-id: 29ede06f4963112e4c4e0536fd99190d1cc7c3d8 --- eden/fs/service/EdenServer.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/eden/fs/service/EdenServer.cpp b/eden/fs/service/EdenServer.cpp index aa63664b06d4c..0b9b72d4384d4 100644 --- a/eden/fs/service/EdenServer.cpp +++ b/eden/fs/service/EdenServer.cpp @@ -2759,13 +2759,32 @@ void EdenServer::runEdenDoctor() { // than reusing it. Explanation on why CPUThreadPoolExecutor- // https://www.internalfb.com/intern/staticdocs/fbcref/guides/Executors/. folly::CPUThreadPoolExecutor executor(1); - executor.add([] { + auto systemConfigDir = config_->getEdenConfig()->getSystemConfigDir(); + auto edenDir = getEdenDir(); + executor.add([systemConfigDir, edenDir] { try { XLOG(INFO, "Running periodic eden doctor dry-run."); + // Not passing Options field cause "0x57" error. ref: D59783277 + SpawnedProcess::Options opts; +#ifdef _WIN32 + opts.creationFlags(CREATE_NO_WINDOW); + opts.nullStderr(); + opts.nullStdin(); + opts.nullStdout(); +#endif // _WIN32 // Assuming, this will only be run from windows user's system, // we are using the plain vanilla version of eden doctor dry run. // This can be modified in the future to pass config-dir param. - auto proc = SpawnedProcess({"edenfsctl", "doctor", "--dry-run"}); + auto proc = SpawnedProcess( + {"c:\\tools\\eden\\bin\\edenfsctl.exe", + "--etc-eden-dir", + systemConfigDir.c_str(), + "--config-dir", + edenDir.asString(), + "doctor", + "--dry-run", + "--fast"}, + std::move(opts)); XLOG(INFO, "Checking status for eden doctor dry-run."); // Setting the timeout to terminate process to 2.5 minutes. // P99.9 to run eden doctor dry-run is ~2 minutes.