Skip to content

Commit 5bc76ab

Browse files
ViniGupta08facebook-github-bot
authored andcommitted
Fix eden health check exit code
Summary: **Background**: Previously, when detecting issues with the Eden setup, we would send an exit code of 1 to identify the issue on the VS Code side. However, VS Code's execution logic would interpret this exit code as a command execution failure, causing it to terminate the code flow prematurely and preventing the reporting of Eden-related issues to the end user. **Changes**: To address this issue, we have introduced a custom isExitError method within VS Code's execution logic. This method ensures that an exit code of 1 is treated as a non-error scenario, allowing the code flow to continue uninterrupted when Eden-related issues are detected. With this change, VS Code will no longer terminate prematurely due to Eden issues, enabling more robust error handling and improved user experience. Reviewed By: genevievehelsel Differential Revision: D67868950 fbshipit-source-id: 5948e692df4f4e447834c63b413d9b3e503373d1
1 parent b77c543 commit 5bc76ab

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

eden/fs/cli/main.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,11 @@ class ErrorCode(Enum):
12201220

12211221
def description(self) -> str:
12221222
descriptions = {
1223-
self.EDEN_NOT_RUNNING: "The EdenFS daemon is not running.",
1223+
self.EDEN_NOT_RUNNING: "The EdenFS daemon doesn't seem to be running.",
12241224
self.STALE_EDEN_VERSION: "The running EdenFS daemon is over 30 days out-of-date.",
1225-
self.INVALID_CERTS: "The EdenFS couldn't find a valid user certificate.",
1226-
self.NO_REPO_MOUNT_FOUND: "One or more checkouts are unmounted: ",
1227-
self.CHEF_NOT_RUNNING: "Chef is not running on your machine.",
1225+
self.INVALID_CERTS: "EdenFS couldn't find a valid user certificate.",
1226+
self.NO_REPO_MOUNT_FOUND: "One or more checkouts are identified as unmounted.",
1227+
self.CHEF_NOT_RUNNING: "Chef doesn't seem to be running on your machine.",
12281228
}
12291229
return descriptions[self]
12301230

@@ -1245,22 +1245,22 @@ def is_eden_running(self, instance: EdenInstance) -> bool:
12451245
health_info = instance.check_health()
12461246
if not health_info.is_healthy():
12471247
self.error_codes[HealthReportCmd.ErrorCode.EDEN_NOT_RUNNING] = (
1248-
"Could not find EdenFS daemon pid."
1248+
"Failed to find EdenFS daemon pid"
12491249
)
12501250
return False
12511251

12521252
try:
12531253
self.running_version = instance.get_running_version()
12541254
except EdenNotRunningError:
12551255
self.error_codes[HealthReportCmd.ErrorCode.EDEN_NOT_RUNNING] = (
1256-
"Couldn't retrieve EdenFS running version."
1256+
"Failed to retrieve EdenFS running version"
12571257
)
12581258
return False
12591259

12601260
self.version_info = version_mod.get_version_info(self.running_version)
12611261
if not self.version_info.is_eden_running:
12621262
self.error_codes[HealthReportCmd.ErrorCode.EDEN_NOT_RUNNING] = (
1263-
"Couldn't retrieve EdenFS running version."
1263+
"Failed to retrieve EdenFS running version"
12641264
)
12651265
return False
12661266
return True
@@ -1284,7 +1284,7 @@ def are_certs_valid(self) -> bool:
12841284
return True
12851285
# cert error!
12861286
self.error_codes[HealthReportCmd.ErrorCode.INVALID_CERTS] = (
1287-
"Couldn't validate x509 certificates."
1287+
"Failed to validate x509 certificates"
12881288
)
12891289
return False
12901290

@@ -1299,17 +1299,20 @@ def is_repo_mounted(self, instance: EdenInstance, mounts: List[str]) -> bool:
12991299

13001300
if unmounted_repos:
13011301
self.error_codes[HealthReportCmd.ErrorCode.NO_REPO_MOUNT_FOUND] = (
1302-
", ".join(unmounted_repos)
1302+
", ".join(unmounted_repos) + " not mounted correctly"
13031303
)
13041304
return False
13051305

13061306
return True
1307+
13071308
except Exception as ex:
1308-
print(f"Couldn't retrieve EdenFS checkouts info.: {ex}", file=sys.stderr)
1309-
return True
1309+
self.error_codes[HealthReportCmd.ErrorCode.NO_REPO_MOUNT_FOUND] = " ".join(
1310+
["Failed to retrieve EdenFS checkouts info: ", ex.args[0]]
1311+
)
1312+
return False
13101313

13111314
def is_chef_running(self) -> bool:
1312-
"""Examine the status of Chef."""
1315+
"""Examine the status of Chef runs."""
13131316
chef_log_path = get_chef_log_path(platform.system())
13141317
if chef_log_path is None or chef_log_path == "":
13151318
print(f"Skipping chef run check for platform {platform.system()}.")
@@ -1321,9 +1324,10 @@ def is_chef_running(self) -> bool:
13211324
last_chef_run_sec = chef_log[CHEF_LOG_TIMESTAMP_KEY]
13221325

13231326
if not isinstance(last_chef_run_sec, (int, float)):
1324-
raise ValueError(
1325-
f"Invalid/missing timestamp in {CHEF_LOG_TIMESTAMP_KEY}"
1327+
self.error_codes[HealthReportCmd.ErrorCode.CHEF_NOT_RUNNING] = (
1328+
"Invalid/missing timestamp in " + CHEF_LOG_TIMESTAMP_KEY
13261329
)
1330+
return False
13271331

13281332
last_chef_run = datetime.fromtimestamp(last_chef_run_sec)
13291333

@@ -1335,7 +1339,7 @@ def is_chef_running(self) -> bool:
13351339
self.error_codes[HealthReportCmd.ErrorCode.CHEF_NOT_RUNNING] = (
13361340
"Last run was "
13371341
+ str((ms_since_last_run / 3600000))
1338-
+ " hours ago."
1342+
+ " hours ago"
13391343
)
13401344
return False
13411345
return True
@@ -1362,7 +1366,9 @@ def print_error_codes_json(out: ui.Output) -> None:
13621366
data = [
13631367
{
13641368
"error": error_code.name,
1365-
"description": error_code.description() + error_additional_info,
1369+
"description": error_additional_info
1370+
+ ". Possible causes: "
1371+
+ error_code.description(),
13661372
}
13671373
for error_code, error_additional_info in HealthReportCmd.error_codes.items()
13681374
]
@@ -1389,11 +1395,12 @@ def run(self, args: argparse.Namespace) -> int:
13891395
)
13901396
):
13911397
exit_code = 1
1392-
except Exception as ex:
1393-
print(ex)
13941398

1395-
self.print_error_codes_json(out)
1396-
return exit_code
1399+
self.print_error_codes_json(out)
1400+
return exit_code
1401+
1402+
except Exception as ex:
1403+
raise Exception("Failed to run health report: " + str(ex))
13971404

13981405

13991406
@subcmd("strace", "Monitor FUSE requests.")

eden/fs/cli/test/health_report_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_health_report_notify_eden_not_running(
158158
self.assertEqual(
159159
HealthReportCmd.error_codes,
160160
{
161-
HealthReportCmd.ErrorCode.EDEN_NOT_RUNNING: "Could not find EdenFS daemon pid.",
161+
HealthReportCmd.ErrorCode.EDEN_NOT_RUNNING: "Failed to find EdenFS daemon pid",
162162
},
163163
)
164164

@@ -252,7 +252,7 @@ def test_health_report_check_for_invalid_certs(
252252
self.assertEqual(
253253
HealthReportCmd.error_codes,
254254
{
255-
HealthReportCmd.ErrorCode.INVALID_CERTS: "Couldn't validate x509 certificates."
255+
HealthReportCmd.ErrorCode.INVALID_CERTS: "Failed to validate x509 certificates"
256256
},
257257
)
258258

0 commit comments

Comments
 (0)