From 6e505affde45168ca3246f9377fa880dbe624c76 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Wed, 26 Jun 2019 13:55:32 +0200 Subject: build: add timestamps to start/end of build During recent CI issues I got an idea that it would be nice to have information how much time building specific image took. On local systems we can do log and then check 'modified_time - creation_time' but not on CI jobs. Fresh image: INFO:kolla.common.utils.base:Building started at 2019-06-26 13:53:08.393544 INFO:kolla.common.utils.base:Ended at 2019-06-26 13:56:40.354761 (took 0:03:31.961225) Rebuild: INFO:kolla.common.utils.base:Building started at 2019-06-26 14:00:34.913194 INFO:kolla.common.utils.base:Built at 2019-06-26 14:00:38.988874 (took 0:00:04.075686) Failed images do not get second line due to logger.exception() being used. Change-Id: Id13545224fa0fbb729d46386a10505e0989fc3c6 --- kolla/image/build.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'kolla') diff --git a/kolla/image/build.py b/kolla/image/build.py index 4e37677d3..83e8f85cd 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -489,7 +489,8 @@ class BuildTask(DockerTask): return image.status = STATUS_BUILDING - self.logger.info('Building') + image.start = datetime.datetime.now() + self.logger.info('Building started at %s' % image.start) if image.source and 'source' in image.source: self.process_source(image, image.source) @@ -554,7 +555,9 @@ class BuildTask(DockerTask): self.logger.exception('Unknown error when building') else: image.status = STATUS_BUILT - self.logger.info('Built') + now = datetime.datetime.now() + self.logger.info('Built at %s (took %s)' % + (now, now - image.start)) def squash(self): image_tag = self.image.canonical_name -- cgit v1.2.3