Skip to content

Commit dfac531

Browse files
Optimize control flow, make initial cleanup failures fatal
Signed-off-by: Markus Hentsch <[email protected]>
1 parent a461805 commit dfac531

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Tests/iaas/volume-backup/volume-backup-tester.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,22 @@ def main():
332332
cloud,
333333
password=getpass.getpass("Enter password: ") if args.ask else None
334334
)
335+
336+
if not cleanup(conn, prefix=args.prefix, timeout=args.timeout):
337+
raise Exception(
338+
f"Cleanup was not successful, there may be leftover resources "
339+
f"with the '{args.prefix}' prefix"
340+
)
335341
if args.cleanup_only:
342+
return
343+
try:
344+
test_backup(conn, prefix=args.prefix, timeout=args.timeout)
345+
finally:
336346
if not cleanup(conn, prefix=args.prefix, timeout=args.timeout):
337-
raise Exception(
338-
f"Cleanup was not successful, there may be leftover resources "
339-
f"with the '{args.prefix}' prefix"
347+
logging.info(
348+
f"There may be leftover resources with the "
349+
f"'{args.prefix}' prefix that could not be cleaned up!"
340350
)
341-
else:
342-
cleanup(conn, prefix=args.prefix, timeout=args.timeout)
343-
try:
344-
test_backup(conn, prefix=args.prefix, timeout=args.timeout)
345-
finally:
346-
if not cleanup(conn, prefix=args.prefix, timeout=args.timeout):
347-
logging.info(
348-
f"There may be leftover resources with the "
349-
f"'{args.prefix}' prefix that could not be cleaned up!"
350-
)
351351

352352

353353
if __name__ == "__main__":

0 commit comments

Comments
 (0)