mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #38491 from gtmanfred/timing
Use UTC for timing in case timezone changes
This commit is contained in:
commit
c5ba11b5e0
@ -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…
Reference in New Issue
Block a user