From 980c7ba8fbdf900c1ae6a3d175a664370e8edf2a Mon Sep 17 00:00:00 2001 From: Ozan Unsal Date: Mon, 16 Aug 2021 09:36:13 +0200 Subject: [PATCH] Handle the pungi failures to ensure creation of log files If the given directory is not a valid git directory, it raises RuntimeError. This can be catched and raised as GitUrlResolveError, so compose can continue to log the failure. Jira: RHELCMP-6077 Signed-off-by: Ozan Unsal --- pungi/scripts/pungi_koji.py | 9 ++++++++- pungi/util.py | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pungi/scripts/pungi_koji.py b/pungi/scripts/pungi_koji.py index b63ddd6e..c262e775 100644 --- a/pungi/scripts/pungi_koji.py +++ b/pungi/scripts/pungi_koji.py @@ -272,7 +272,7 @@ def main(): logger, opts.skip_phase + conf.get("skip_phases", []), opts.just_phase ): sys.exit(1) - errors, warnings = pungi.checks.validate(conf) + errors, warnings = pungi.checks.validate(conf, offline=True) if not opts.quiet: # TODO: workaround for config files containing skip_phase = productimg @@ -328,6 +328,13 @@ def main(): logger=logger, notifier=notifier, ) + errors, warnings = pungi.checks.validate(conf, offline=False) + if errors: + for error in errors: + logger.error("Config validation failed with the error: %s" % error) + fail_to_start("Config validation failed", errors=errors) + sys.exit(1) + notifier.compose = compose COMPOSE = compose try: diff --git a/pungi/util.py b/pungi/util.py index da5e82f2..c6a40d4d 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -288,8 +288,12 @@ def resolve_git_ref(repourl, ref): if re.match(r"^[a-f0-9]{40}$", ref): # This looks like a commit ID already. return ref - - _, output = git_ls_remote(repourl, ref) + try: + _, output = git_ls_remote(repourl, ref) + except RuntimeError as e: + raise GitUrlResolveError( + "ref does not exist in remote repo %s with the error %s" % (repourl, e) + ) lines = [] for line in output.split("\n"):