handle exception in converting datetime to seconds
@@ -382,7 +382,7 @@ class Watcher:
# fluentd logs timestamp format : 2018-08-02 19:27:34 +0000
# for python 2.7 or earlier there is no good way to convert it into seconds.
# so we parse upto seconds, and parse utc specific offset seperately.
-
+ try:
date_time_format = '%Y-%m-%d %H:%M:%S'
epoch = datetime(1970, 1, 1)
@@ -392,6 +392,10 @@ class Watcher:
log_time = datetime.strptime(datetime_string[:19], date_time_format) + ((timedelta(hours=hours_delta_utc, minutes=minutes_delta_utc)) * (-1 if datetime_string[20] == "+" else 1))
return (log_time - epoch).total_seconds()
+ except Exception as e:
+ self._hutil_error('Error converting timestamp string to seconds. Exception={0}'.format(e))
+
+ return 0
def check_for_fatal_oms_logs(self, log_file_marker):
"""
