From 5d4d2104069054fea00b0d46ad797fe1b264fc1d Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 25 Jan 2016 10:31:04 +0000 Subject: More robust creation of tempdirs 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 --- morphlib/app.py | 11 +++++++++-- 1 file 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) -- cgit v1.2.1