From: Bartek Grzybowski Date: Mon, 16 Nov 2020 14:39:08 +0000 (+0100) Subject: Fix race condition while creating dest dir for docker images X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=43276843ffb0e3d78178b92af5e2840e9642fd50;p=oom%2Foffline-installer.git Fix race condition while creating dest dir for docker images Docker_downloader module uses threads to concurrently save docker images to dest dir which creation is not guarded with any kind of thread lock object thus it could fail on os.makedirs as other thread could have already created that dir. Hence "exist_ok=True" opt is added to os.makedirs call so that it does not fail in such circumstances. Change-Id: I6e2d2c9864b71d038e7b2ed3018cdd3c01916956 Issue-ID: OOM-2631 Signed-off-by: Bartek Grzybowski --- diff --git a/build/download/docker_downloader.py b/build/download/docker_downloader.py index 27dde12f..847bc180 100755 --- a/build/download/docker_downloader.py +++ b/build/download/docker_downloader.py @@ -168,8 +168,7 @@ class DockerDownloader(ConcurrentDownloader): :param image_name: name of the image from list """ dst = '{}/{}'.format(output_dir, self._image_filename(image_name)) - if not os.path.exists(output_dir): - os.makedirs(output_dir) + os.makedirs(output_dir, exist_ok=True) try: with open(dst, 'wb') as f: for chunk in image.save(named=self.image_registry_name(image_name)):