mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
record start/stop duration for parallel processes separately
previously durations were only recording the time to spawn the multiprocessing proc, not the actual time of completion, which is completely wrong. This should capture the full duration correctly now. We unfortunately have to duplicate start & complete times instead of using the passed in start_time attr, as that value is only a time (not date), so it is impossible to re-calculate the full duration based on that alone (ie, what happens if start_time is 23:59 with a roll-over to the next day). This fixes #44828
This commit is contained in:
parent
e4844bdf2b
commit
26a96e8933
1 changed files with 12 additions and 0 deletions
|
@ -1697,6 +1697,10 @@ class State(object):
|
|||
'''
|
||||
The target function to call that will create the parallel thread/process
|
||||
'''
|
||||
# we need to re-record start/end duration here because it is impossible to
|
||||
# correctly calculate further down the chain
|
||||
utc_start_time = datetime.datetime.utcnow()
|
||||
|
||||
tag = _gen_tag(low)
|
||||
try:
|
||||
ret = self.states[cdata['full']](*cdata['args'],
|
||||
|
@ -1721,6 +1725,14 @@ class State(object):
|
|||
'comment': 'An exception occurred in this state: {0}'.format(
|
||||
trb)
|
||||
}
|
||||
|
||||
utc_finish_time = datetime.datetime.utcnow()
|
||||
delta = (utc_finish_time - utc_start_time)
|
||||
# duration in milliseconds.microseconds
|
||||
duration = (delta.seconds * 1000000 + delta.microseconds)/1000.0
|
||||
ret['duration'] = duration
|
||||
|
||||
|
||||
troot = os.path.join(self.opts['cachedir'], self.jid)
|
||||
tfile = os.path.join(troot, _clean_tag(tag))
|
||||
if not os.path.isdir(troot):
|
||||
|
|
Loading…
Add table
Reference in a new issue