@@ -1317,6 +1317,30 @@ def remote_handler(options, operations): # pylint: disable=too-many-branches,to
1317
1317
err )
1318
1318
ret = err .code
1319
1319
1320
+ elif operation == "check_disk" :
1321
+ if _IS_WINDOWS :
1322
+ partitions = psutil .disk_partitions ()
1323
+ for part in partitions :
1324
+ if part .fstype != "NTFS" or part .mountpoint == "C:\\ " :
1325
+ # Powercycle testing in Evergreen only writes to the D: and E: drives on the
1326
+ # remote machine. We skip running the chkdsk command on the C: drive because
1327
+ # it sometimes fails with a "Snapshot was deleted" error. We assume the
1328
+ # system drive is functioning properly because the remote machine rebooted
1329
+ # fine anyway.
1330
+ continue
1331
+
1332
+ # The chkdsk command won't accept the drive if it has a trailing backslash.
1333
+ # We use os.path.splitdrive()[0] to transform 'C:\\' into 'C:'.
1334
+ drive_letter = os .path .splitdrive (part .mountpoint )[0 ]
1335
+ LOGGER .info ("Running chkdsk command for %s drive" , drive_letter )
1336
+ cmds = f"chkdsk '{ drive_letter } '"
1337
+ ret , output = execute_cmd (cmds , use_file = True )
1338
+ LOGGER .warning ("chkdsk command for %s drive exited with code %d:\n %s" ,
1339
+ drive_letter , ret , output )
1340
+
1341
+ if ret != 0 :
1342
+ return ret
1343
+
1320
1344
else :
1321
1345
LOGGER .error ("Unsupported remote option specified '%s'" , operation )
1322
1346
ret = 1
@@ -2569,6 +2593,11 @@ def main(): # pylint: disable=too-many-branches,too-many-locals,too-many-statem
2569
2593
if loop_num == options .num_loops or test_time >= options .test_time :
2570
2594
break
2571
2595
2596
+ ret , output = call_remote_operation (local_ops , options .remote_python , script_name ,
2597
+ client_args , "--remoteOperation check_disk" )
2598
+ if ret != 0 :
2599
+ LOGGER .error ("****check_disk: %d %s****" , ret , output )
2600
+
2572
2601
REPORT_JSON_SUCCESS = True
2573
2602
local_exit (0 )
2574
2603
0 commit comments