[oe-commits] [openembedded-core] 29/63: buildstats.py: skip collecting unavailable /proc data
git at git.openembedded.org
git at git.openembedded.org
Tue Dec 13 22:56:47 UTC 2016
rpurdie pushed a commit to branch master
in repository openembedded-core.
commit daeee2d6731014c33f0d1f8a3846830c099932b4
Author: Patrick Ohly <patrick.ohly at intel.com>
AuthorDate: Fri Dec 9 09:40:20 2016 +0100
buildstats.py: skip collecting unavailable /proc data
Some virtualized environments like Linux-VServer do not have the
entries under /proc that the new system usage sampling expected,
leading to an exception when trying to open the files.
Now the presence of these files is checked once before enabling the
corresponding data collection. When a file is missing, the
corresponding log file is not written either and pybootchart will not
draw the chart that normally displays the data.
Errors while reading or writing of data samples is intentionally still
a fatal error, because that points towards a bigger problem that
should not be ignored.
Reported-by: Andreas Oberritter <obi at opendreambox.org>
Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
---
meta/lib/buildstats.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/meta/lib/buildstats.py b/meta/lib/buildstats.py
index 9e5b6be..854c387 100644
--- a/meta/lib/buildstats.py
+++ b/meta/lib/buildstats.py
@@ -18,13 +18,18 @@ class SystemStats:
('meminfo', self._reduce_meminfo),
('stat', self._reduce_stat),
):
- # In practice, this class gets instantiated only once in
- # the bitbake cooker process. Therefore 'append' mode is
- # not strictly necessary, but using it makes the class
- # more robust should two processes ever write
- # concurrently.
- destfile = os.path.join(bsdir, '%sproc_%s.log' % ('reduced_' if handler else '', filename))
- self.proc_files.append((filename, open(destfile, 'ab'), handler))
+ # The corresponding /proc files might not exist on the host.
+ # For example, /proc/diskstats is not available in virtualized
+ # environments like Linux-VServer. Silently skip collecting
+ # the data.
+ if os.path.exists(os.path.join('/proc', filename)):
+ # In practice, this class gets instantiated only once in
+ # the bitbake cooker process. Therefore 'append' mode is
+ # not strictly necessary, but using it makes the class
+ # more robust should two processes ever write
+ # concurrently.
+ destfile = os.path.join(bsdir, '%sproc_%s.log' % ('reduced_' if handler else '', filename))
+ self.proc_files.append((filename, open(destfile, 'ab'), handler))
self.monitor_disk = open(os.path.join(bsdir, 'monitor_disk.log'), 'ab')
# Last time that we sampled /proc data resp. recorded disk monitoring data.
self.last_proc = 0
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list