diff options
| author | Martin André <m.andre@redhat.com> | 2015-12-11 17:45:03 +0900 |
|---|---|---|
| committer | Martin André <m.andre@redhat.com> | 2015-12-11 20:07:02 +0900 |
| commit | 06794fdc6b6bba7030866c2828376d07f3596343 (patch) | |
| tree | 269537d83ebd7731fdb97dab7149f19fe0fa70c3 /kolla | |
| parent | a98628453b0c1fc72692376abd873cbccb5a35a9 (diff) | |
| download | kolla-06794fdc6b6bba7030866c2828376d07f3596343.tar.gz kolla-06794fdc6b6bba7030866c2828376d07f3596343.zip | |
Catch exception when directory creation fails
The build script now creates now creates a plugins directory for source
builds to store plugins required for the container, and creates a tar
of all plugins that is extracted at runtime.
However, the creation of the 'plugins' directory is not handled
correctly and generate an exception in the running thread if the
directory exists. This is the case for example if the build script
retries a failing image.
This commit fixes the timeout issues we've experienced with the gate.
Change-Id: Ic5d4fd1ddf71f01c547130518e311fded911c445
Closes-Bug: 1524897
Diffstat (limited to 'kolla')
| -rwxr-xr-x | kolla/cmd/build.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py index dba153458..216d9d48b 100755 --- a/kolla/cmd/build.py +++ b/kolla/cmd/build.py @@ -16,6 +16,7 @@ import argparse import datetime +import errno import json import logging import os @@ -168,6 +169,7 @@ class WorkerThread(Thread): return plugin_archives = list() + plugins_path = os.path.join(image['path'], 'plugins') for plugin in image['plugins']: archive_path = self.process_source(image, plugin) if image['status'] == "error": @@ -176,13 +178,22 @@ class WorkerThread(Thread): if plugin_archives: for plugin_archive in plugin_archives: with tarfile.open(plugin_archive, 'r') as plugin_archive_tar: - plugin_archive_tar.extractall( - path=os.path.join(image['path'], 'plugins')) + plugin_archive_tar.extractall(path=plugins_path) else: - os.mkdir(os.path.join(image['path'], 'plugins')) + try: + os.mkdir(plugins_path) + except OSError as e: + if e.errno == errno.EEXIST: + LOG.info('Directory {} already exist. Skipping.'.format( + plugins_path)) + else: + LOG.error('Failed to create directory {}: {}'.format( + plugins_path, e)) + image['status'] = "error" + return with tarfile.open(os.path.join(image['path'], 'plugins-archive'), 'w') as tar: - tar.add(os.path.join(image['path'], 'plugins'), arcname='plugins') + tar.add(plugins_path, arcname='plugins') # Pull the latest image for the base distro only pull = True if image['parent'] is None else False |
