Add some tracking for image sizes

Use dib's DIB_SHOW_IMAGE_USAGE flag to make sure we have a report in
the build logs of files and directories >10MiB in the build image.

Add a new gauge stat to measure the size of the built images.

With this, we can make a dashboard to monitor the trend, and if we see
a spike, we should be able to quickly pull out the reason for it from
the logs.

Change-Id: Id94c7f1fabe2e79b162025c8fc4e5ee243b0a8b9
Depends-On: I255800790a62fed1c82fcd311f1cc29c9867766d
This commit is contained in:
Ian Wienand
2016-03-08 14:10:01 +11:00
parent 536f7feab0
commit b2b6fa4610

View File

@@ -397,6 +397,10 @@ class NodePoolBuilder(object):
if self._config.scriptdir:
env['NODEPOOL_SCRIPTDIR'] = self._config.scriptdir
# this puts a disk-usage report in the logs so we can see if
# something blows up the image size.
env['DIB_SHOW_IMAGE_USAGE'] = '1'
# send additional env vars if needed
for k, v in image.env_vars.items():
env[k] = v
@@ -445,6 +449,20 @@ class NodePoolBuilder(object):
"DIB failed creating %s" % filename
)
if self.statsd:
# record stats on the size of each image we create
for ext in img_types.split(','):
key = 'nodepool.dib_image_build.%s.%s.size' % (image.name, ext)
# A bit tricky because these image files may be sparse
# files; we only want the true size of the file for
# purposes of watching if we've added too much stuff
# into the image. Note that st_blocks is defined as
# 512-byte blocks by stat(2)
size = os.stat("%s.%s" % (filename, ext)).st_blocks * 512
self.log.debug("%s created image %s.%s (size: %d) " %
(image.name, filename, ext, size))
self.statsd.gauge(key, size)
def _getDiskimageByName(self, name):
for image in self._config.diskimages.values():
if image.name == name: