From 867e357eb14cf0c2d91bd9ee734b26f7a1c0c058 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 16 May 2019 15:38:36 -0500 Subject: [PATCH] When not using file_per_task, make sure we don't prematurely close the perf files (#56477) * When not using file_per_task, make sure we don't prematurely close the perf files * add changelog fragment --- .../cgroup-perf-recap-fix-open-files.yaml | 2 ++ .../plugins/callback/cgroup_perf_recap.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/cgroup-perf-recap-fix-open-files.yaml diff --git a/changelogs/fragments/cgroup-perf-recap-fix-open-files.yaml b/changelogs/fragments/cgroup-perf-recap-fix-open-files.yaml new file mode 100644 index 00000000000..ce5474e21de --- /dev/null +++ b/changelogs/fragments/cgroup-perf-recap-fix-open-files.yaml @@ -0,0 +1,2 @@ +bugfixes: +- cgroup_perf_recap - When not using file_per_task, make sure we don't prematurely close the perf files diff --git a/lib/ansible/plugins/callback/cgroup_perf_recap.py b/lib/ansible/plugins/callback/cgroup_perf_recap.py index d9897756c82..c21d3e2f81e 100644 --- a/lib/ansible/plugins/callback/cgroup_perf_recap.py +++ b/lib/ansible/plugins/callback/cgroup_perf_recap.py @@ -394,13 +394,14 @@ class CallbackModule(CallbackBase): def _profile(self, obj=None): prev_task = None results = dict.fromkeys(self._features) - for dummy, f in self._files.items(): - if f is None: - continue - try: - f.close() - except Exception: - pass + if not obj or self._file_per_task: + for dummy, f in self._files.items(): + if f is None: + continue + try: + f.close() + except Exception: + pass try: for name, prof in self._profilers.items(): @@ -420,7 +421,7 @@ class CallbackModule(CallbackBase): pass if obj is not None: - if self._file_per_task: + if self._file_per_task or self._counter == 0: self._open_files(task_uuid=obj._uuid) for feature in self._features: