From 5acfb90b23ffacd6be92e1262571143ce42463e4 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Fri, 7 Jul 2017 09:31:59 -0600 Subject: [PATCH] createrepo: handle missing product ids scm dir Prior to this change, if the entire product IDs SCM directory was missing, pungi would crash with an error. For example, if "ceph-3" was missing from the SCM: OSError: [Errno 2] No such file or directory: '/tmp/tmpMb9O6r/product_ids/ceph-3' This occurred even if product_id_allow_missing was set to True. Make product_id_allow_missing cover this case as well, and gracefully skip all product IDs. We now see the following warning in the logs instead: [WARNING ] No product IDs in {'scm': 'git', 'repo': 'git://example.com/rcm/rcm-metadata.git', 'dir': 'product_ids/ceph-3'} and the compose succeeds. Signed-off-by: Ken Dreyer --- pungi/phases/createrepo.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index ee6e320b..5ab65f49 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -24,6 +24,7 @@ import glob import shutil import threading import copy +import errno from kobo.threads import ThreadPool, WorkerThread from kobo.shortcuts import run, relative_path @@ -231,7 +232,13 @@ def get_productids_from_scm(compose): compose.log_info("[BEGIN] %s" % msg) tmp_dir = compose.mkdtemp(prefix="pungi_") - get_dir_from_scm(product_id, tmp_dir) + try: + get_dir_from_scm(product_id, tmp_dir) + except OSError as e: + if e.errno == errno.ENOENT and product_id_allow_missing: + compose.log_warning("No product IDs in %s" % product_id) + return + raise for arch in compose.get_arches(): for variant in compose.get_variants(arch=arch):