From 02f00d93c1e530b08c16cadfb8f0b8cc79ac599d Mon Sep 17 00:00:00 2001 From: mprahl Date: May 06 2019 15:13:23 +0000 Subject: Add debug log statements so that SCM problems are easier to debug in the future --- diff --git a/module_build_service/scm.py b/module_build_service/scm.py index d2c1b55..a241c95 100644 --- a/module_build_service/scm.py +++ b/module_build_service/scm.py @@ -217,10 +217,11 @@ class SCM(object): # fallbac to `get_full_commit_hash`. We do not want to retry here, because # in case module contains only commit hashes, it would block for very long # time. - _, output, _ = SCM._run_without_retry( - ["git", "ls-remote", "--exit-code", self.repository, "refs/heads/" + ref] - ) + cmd = ["git", "ls-remote", "--exit-code", self.repository, "refs/heads/" + ref] + log.debug("Checking to see if the ref %s is a branch with `%s`", ref, " ".join(cmd)) + _, output, _ = SCM._run_without_retry(cmd) except UnprocessableEntity: + log.debug("The ref %s is not a branch. Checking to see if it's a commit hash", ref) # The call below will either return the commit hash as is (if a full one was # provided) or the full commit hash (if a short hash was provided). If ref is not # a commit hash, then this will raise an exception. @@ -248,12 +249,19 @@ class SCM(object): raise RuntimeError('No commit hash was specified for "{0}"'.format(self.url)) if self.scheme == "git": - log.debug('Getting the full commit hash for "{0}"'.format(self.repository)) + log.debug( + "Getting the full commit hash on %s from %s", self.repository, commit_to_check) td = None try: td = tempfile.mkdtemp() SCM._run(["git", "clone", "-q", self.repository, td, "--bare"]) - output = SCM._run(["git", "rev-parse", commit_to_check], chdir=td)[1] + cmd = ["git", "rev-parse", commit_to_check] + log.debug( + "Running `%s` to get the full commit hash for %s", + " ".join(cmd), + commit_to_check + ) + output = SCM._run(cmd, chdir=td)[1] finally: if td and os.path.exists(td): shutil.rmtree(td) diff --git a/module_build_service/utils/submit.py b/module_build_service/utils/submit.py index ebcc464..976fa96 100644 --- a/module_build_service/utils/submit.py +++ b/module_build_service/utils/submit.py @@ -105,7 +105,10 @@ def _scm_get_latest(pkg): # we want to pull from, we need to resolve that f25 branch # to the specific commit available at the time of # submission (now). - pkgref = module_build_service.scm.SCM(pkg.get_repository()).get_latest(pkg.get_ref()) + repo = pkg.get_repository() + ref = pkg.get_ref() + log.debug("Getting the commit hash for the ref %s on the repo %s", ref, repo) + pkgref = module_build_service.scm.SCM(repo).get_latest(ref) except Exception as e: log.exception(e) return {