Pass compose parameter for debugging git issue

With this param, get_dir_from_scm will try to copy the tmp git dir to
compose target dir when error occurs.

This does not fix the issue but it would be helpful for debugging when
it occurs again.

JIRA: RHELCMP-7244
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2021-11-26 12:03:03 +08:00
parent 5e6248e3e0
commit 20c2e59218
2 changed files with 26 additions and 7 deletions

View File

@ -81,6 +81,7 @@ class CreaterepoPhase(PhaseBase):
get_dir_from_scm(
self.compose.conf["createrepo_extra_modulemd"][variant.uid],
self.compose.paths.work.tmp_dir(variant=variant, create_dir=False),
compose=self.compose,
)
self.pool.queue_put((self.compose, None, variant, "srpm"))
@ -363,7 +364,7 @@ def get_productids_from_scm(compose):
tmp_dir = compose.mkdtemp(prefix="pungi_")
try:
get_dir_from_scm(product_id, tmp_dir)
get_dir_from_scm(product_id, tmp_dir, compose=compose)
except OSError as e:
if e.errno == errno.ENOENT and product_id_allow_missing:
compose.log_warning("No product IDs in %s" % product_id)

View File

@ -141,7 +141,13 @@ class TestCreaterepoPhase(PungiTestCase):
self.assertEqual(
get_dir_from_scm.call_args_list,
[mock.call(scm, os.path.join(compose.topdir, "work/global/tmp-Server"))],
[
mock.call(
scm,
os.path.join(compose.topdir, "work/global/tmp-Server"),
compose=compose,
)
],
)
@ -1333,7 +1339,7 @@ class TestCreateVariantRepo(PungiTestCase):
class TestGetProductIds(PungiTestCase):
def mock_get(self, filenames):
def _mock_get(scm, dest):
def _mock_get(scm, dest, compose=None):
for filename in filenames:
touch(os.path.join(dest, filename))
@ -1379,7 +1385,10 @@ class TestGetProductIds(PungiTestCase):
get_productids_from_scm(self.compose)
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
self.assertEqual(
get_dir_from_scm.call_args_list,
[mock.call(cfg, mock.ANY, compose=self.compose)],
)
self.assertProductIds(
{
"Client": ["amd64"],
@ -1400,7 +1409,10 @@ class TestGetProductIds(PungiTestCase):
get_productids_from_scm(self.compose)
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
self.assertEqual(
get_dir_from_scm.call_args_list,
[mock.call(cfg, mock.ANY, compose=self.compose)],
)
self.assertProductIds({"Server": ["amd64", "x86_64"]})
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
@ -1414,7 +1426,10 @@ class TestGetProductIds(PungiTestCase):
with self.assertRaises(RuntimeError) as ctx:
get_productids_from_scm(self.compose)
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
self.assertEqual(
get_dir_from_scm.call_args_list,
[mock.call(cfg, mock.ANY, compose=self.compose)],
)
self.assertRegex(
str(ctx.exception),
r"No product certificate found \(arch: amd64, variant: (Everything|Client)\)", # noqa: E501
@ -1438,5 +1453,8 @@ class TestGetProductIds(PungiTestCase):
with self.assertRaises(RuntimeError) as ctx:
get_productids_from_scm(self.compose)
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, mock.ANY)])
self.assertEqual(
get_dir_from_scm.call_args_list,
[mock.call(cfg, mock.ANY, compose=self.compose)],
)
self.assertRegex(str(ctx.exception), "Multiple product certificates found.+")