mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use UTC for timing in case timezone changes
Also make sure start time is in the new timezone. Fixes #37684
This commit is contained in:
parent
36e21b22cb
commit
79368c7528
1 changed files with 10 additions and 6 deletions
|
@ -1640,8 +1640,9 @@ class State(object):
|
|||
Call a state directly with the low data structure, verify data
|
||||
before processing.
|
||||
'''
|
||||
start_time = datetime.datetime.now()
|
||||
log.info('Running state [{0}] at time {1}'.format(low['name'], start_time.time().isoformat()))
|
||||
utc_start_time = datetime.datetime.utcnow()
|
||||
local_start_time = utc_start_time - (datetime.datetime.utcnow() - datetime.datetime.now())
|
||||
log.info('Running state [{0}] at time {1}'.format(low['name'], local_start_time.time().isoformat()))
|
||||
errors = self.verify_data(low)
|
||||
if errors:
|
||||
ret = {
|
||||
|
@ -1775,14 +1776,17 @@ class State(object):
|
|||
self.__run_num += 1
|
||||
format_log(ret)
|
||||
self.check_refresh(low, ret)
|
||||
finish_time = datetime.datetime.now()
|
||||
ret['start_time'] = start_time.time().isoformat()
|
||||
delta = (finish_time - start_time)
|
||||
utc_finish_time = datetime.datetime.utcnow()
|
||||
timezone_delta = datetime.datetime.utcnow() - datetime.datetime.now()
|
||||
local_finish_time = utc_finish_time - timezone_delta
|
||||
local_start_time = utc_start_time - timezone_delta
|
||||
ret['start_time'] = local_start_time.time().isoformat()
|
||||
delta = (utc_finish_time - utc_start_time)
|
||||
# duration in milliseconds.microseconds
|
||||
duration = (delta.seconds * 1000000 + delta.microseconds)/1000.0
|
||||
ret['duration'] = duration
|
||||
ret['__id__'] = low['__id__']
|
||||
log.info('Completed state [{0}] at time {1} duration_in_ms={2}'.format(low['name'], finish_time.time().isoformat(), duration))
|
||||
log.info('Completed state [{0}] at time {1} duration_in_ms={2}'.format(low['name'], local_finish_time.time().isoformat(), duration))
|
||||
return ret
|
||||
|
||||
def call_chunks(self, chunks):
|
||||
|
|
Loading…
Add table
Reference in a new issue