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
This commit is contained in:
parent
a98628453b
commit
06794fdc6b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user