Skip to content

Commit e109669

Browse files
Improve error checking
1 parent e463c64 commit e109669

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ush/python/pygfs/task/globus_hpss.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def execute_transfer_data(self, transfer_set: Dict[str, Any], has_rstprod: bool)
246246

247247
# Initialize a list of status files.
248248
transfer_set["status_files"] = []
249+
transfer_set["xfer_ids"] = []
249250
transfer_set["completed"] = []
251+
transfer_set["successes"] = []
250252

251253
# Tell Sven we have files to send, one at a time
252254
for location in transfer_set["locations"]:
@@ -262,10 +264,13 @@ def execute_transfer_data(self, transfer_set: Dict[str, Any], has_rstprod: bool)
262264

263265
# Parse Sven's output to get the name of the return status file
264266
match = re.search("\"(status_.*)\" in your dropbox", sven_output)
265-
transfer_set["status_files"].append(os.path.join(self.task_config.sven_dropbox, match.group(1)))
267+
status_file = match.group(1)
268+
transfer_set["xfer_ids"].append(status_file.replace("status_", ""))
269+
transfer_set["status_files"].append(os.path.join(self.task_config.sven_dropbox, status_file))
266270

267-
# Initialize 'completed' to false for each file
271+
# Initialize 'completed' and 'success' to false for each file
268272
transfer_set["completed"].append(False)
273+
transfer_set["successes"].append(False)
269274

270275
# Transfer the doorman script to Niagara.
271276
# Note, this assumes we have unattended transfer capability.
@@ -284,7 +289,7 @@ def execute_transfer_data(self, transfer_set: Dict[str, Any], has_rstprod: bool)
284289
# Now wait for the doorman script to run via cron on Niagara.
285290
# Once complete, Sven's dropbox should fill up with status files.
286291
wait_count = 0
287-
sleep_time = 300 # s
292+
sleep_time = 60 # s
288293
timeout_time = 5.75 * 3600 # s
289294
max_wait_count = int(timeout_time / sleep_time)
290295

@@ -295,14 +300,15 @@ def execute_transfer_data(self, transfer_set: Dict[str, Any], has_rstprod: bool)
295300
logger.debug(f"Waiting for the service to complete on {server_name}")
296301
while not all(transfer_set["completed"]) and wait_count < max_wait_count:
297302
sleep(sleep_time)
298-
for i in range(len(transfer_set["status_files"])):
303+
for i in range(len(transfer_set["locations"])):
299304
status_file = transfer_set["status_files"][i]
300305
if os.path.exists(status_file):
301306
# If this is a new status file, check if the transfer was successful
302307
if not transfer_set["completed"][i]:
303308
transfer_set["completed"][i] = True
304309
with open(status_file) as status_handle:
305-
transfer_set["successes"][i] = status_handle.readlines()[-1] == "SUCCESS"
310+
status_string = status_handle.readline().rstrip()
311+
transfer_set["successes"][i] = status_string == f"status.{transfer_set['xfer_ids'][i]} SUCCESS"
306312

307313
if transfer_set["successes"][i]:
308314
logger.info(f"Successfully archived {transfer_set['locations'][i]} to HPSS!")

0 commit comments

Comments
 (0)