From 43276843ffb0e3d78178b92af5e2840e9642fd50 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Mon, 16 Nov 2020 15:39:08 +0100 Subject: 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 --- build/download/docker_downloader.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'build') 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)): -- cgit 1.2.3-korg