summaryrefslogtreecommitdiffstats
path: root/src/utils/tiptorrent.py
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-08-01 14:00:32 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-08-01 18:26:10 +0200
commit49038f125aaadc3967a8eec251a4ea69ec5a8869 (patch)
tree125edd5b8698c09c8ef9bb4e315d87a561517866 /src/utils/tiptorrent.py
parentee0d62db444441be41d99ac4ee5f2de5100cd934 (diff)
src: improve logging messages
Some users have mistakenly reported tiptorrent problems when the process takes a long time. Specifically by rebooting or powering off the client in the middle of the md5sum computation stage, just after the tiptorrent transfer. Same problem occurs when image creation command takes a long period of time. In order to help the user understand the different stages of commands such as image creation or image restore using tiptorrent, the following changes have been made to the current logging solution: - Add log messages to warn users not to reboot or shut down the client during a tiptorrent transfer, and also during the md5sum computation stage. - Add a log message telling the user that the image creation processes have started. - Use logging.exception inside "except:" blocks to print a traceback with the log messsage. (https://docs.python.org/3/library/logging.html#logging.exception)
Diffstat (limited to 'src/utils/tiptorrent.py')
-rw-r--r--src/utils/tiptorrent.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/utils/tiptorrent.py b/src/utils/tiptorrent.py
index 12230c0..d46b1c7 100644
--- a/src/utils/tiptorrent.py
+++ b/src/utils/tiptorrent.py
@@ -62,6 +62,7 @@ def tip_write_csum(image_name):
def tip_check_csum(tip_addr, image_name):
"""
"""
+ logging.info(f'Verifying checksum for {image_name}.img, please wait...')
image_path = f'/opt/opengnsys/cache/opt/opengnsys/images/{image_name}.img'
if not os.path.exists(image_path):
logging.error('Invalid image path')
@@ -78,6 +79,7 @@ def tip_client_get(tip_addr, image_name):
"""
"""
logging.info(f'Fetching image {image_name} from tiptorrent server at {tip_addr}')
+ logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
cmd = f'tiptorrent-client {tip_addr} {image_name}.img'
logfile = open('/tmp/command.log', 'wb', 0)
@@ -87,7 +89,7 @@ def tip_client_get(tip_addr, image_name):
cwd='/opt/opengnsys/cache/opt/opengnsys/images/')
proc.communicate()
except:
- logging.error('Exception when running tiptorrent client GET subprocess')
+ logging.exception('Exception when running tiptorrent client GET subprocess')
raise ValueError('Unexpected error running tiptorrent subprocess')
finally:
logfile.close()
@@ -96,5 +98,6 @@ def tip_client_get(tip_addr, image_name):
logging.error(f'Error fetching image {image_name} via tiptorrent')
raise ValueError('Tiptorrent download failed')
else:
- logging.info('tiptorrent transfer completed, writing checksum')
+ logging.info('Calculating checksum...')
+ logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
tip_write_csum(image_name)