diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-01-25 10:31:04 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-01-25 10:31:35 +0000 |
commit | 5d4d2104069054fea00b0d46ad797fe1b264fc1d (patch) | |
tree | bde3e2f9f194910f390e9d049a205f2c54067b1d | |
parent | fa431c3ce38204f5237337fd2045ad6269413258 (diff) | |
download | morph-5d4d2104069054fea00b0d46ad797fe1b264fc1d.tar.gz |
More robust creation of tempdirsbaserock/pedroalvarez/tempdir-race-conditions-v2
This commit addresses the same issue that we tried to solve in
fa431c3ce38204f5237337fd2045ad6269413258 but this time with temp dirs:
+ echo INFO: Mason building: master at
fe64c00f17a4922c7499f9bc48f672cca293fc65
INFO: Mason building: master at fe64c00f17a4922c7499f9bc48f672cca293fc65
+ scripts/release-build --no-default-configs --trove-host 192.168.222.58
--artifact-cache-server http://192.168.222.14:8080/ --controllers
x86_64:mason-x86-64 clusters/ci.morph
ERROR: /srv/distbuild/tmp/chunks: File exists
ERROR: /srv/distbuild/tmp/chunks: File exists
This has been happening in Mason since we remove every folder
used by Morph after Mason finishes.
Change-Id: I57ad180013117104e7af18e01f6aeccb0011cf6e
-rw-r--r-- | morphlib/app.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index f5871d17..75108fc2 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2015 Codethink Limited +# Copyright (C) 2011-2016 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,6 +14,7 @@ import cliapp +import errno import logging import os import pipes @@ -286,8 +287,14 @@ class Morph(cliapp.Application): os.path.join(tmpdir, 'staging'), os.path.join(tmpdir, 'deployments'), self.settings['cachedir']): - if not os.path.exists(required_dir): + # Don't check the folder exists and handle the exception that + # happens in this case to avoid errors if the folder is created + # by something else just after the check. + try: os.makedirs(required_dir) + except OSError as e: + if e.errno != errno.EEXIST: + raise cliapp.Application.process_args(self, args) |