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 <kdreyer@redhat.com>
This commit is contained in:
Ken Dreyer 2017-07-07 09:31:59 -06:00
parent afffb27f94
commit 5acfb90b23

View File

@ -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):