| |
@@ -156,6 +156,32 @@
|
| |
# job.status = BuildStatus.SKIPPED
|
| |
# self._announce_end(job)
|
| |
|
| |
+ def wait_for_repo(self, job):
|
| |
+ if job.chroot == 'srpm-builds':
|
| |
+ # we don't need copr_base repodata for srpm builds
|
| |
+ return True
|
| |
+
|
| |
+ repodata = os.path.join(job.chroot_dir, "repodata/repomd.xml")
|
| |
+ waiting_from = time.time()
|
| |
+ while time.time() - waiting_from < 60:
|
| |
+ if os.path.exists(repodata):
|
| |
+ return True
|
| |
+
|
| |
+ # Either (a) the very first copr-repo run in this chroot dir
|
| |
+ # is still running on background (or failed), or (b) we are
|
| |
+ # hitting the race condition between
|
| |
+ # 'rm -rf repodata && mv .repodata repodata' sequence that
|
| |
+ # is done in createrepo_c. Try again after some time.
|
| |
+ self.log.info("waiting for copr_base repository")
|
| |
+ time.sleep(2)
|
| |
+
|
| |
+ self.log.error("giving up waiting for copr_base repository")
|
| |
+
|
| |
+ # This should never happen, but if yes - we need to debug
|
| |
+ # properly. Give up waiting, and fail the build. That should
|
| |
+ # motivate people to report bugs.
|
| |
+ return False
|
| |
+
|
| |
def do_job(self, job):
|
| |
"""
|
| |
Executes new job.
|
| |
@@ -178,6 +204,8 @@
|
| |
failed = True
|
| |
|
| |
if not self.reattach:
|
| |
+ if not self.wait_for_repo(job):
|
| |
+ failed = True
|
| |
self.prepare_result_directory(job)
|
| |
|
| |
if not failed:
|
| |
Previously we faced concurrency issues between post-build copr-repo runs
and these pre-build copr-repo runs. The pre-build copr-repo could hit
the small time window when 'repodata' don't exist when craterepo_c is
run (moving .repodata to repodata) and start running our own 'copr-repo'
process mistakenly. That would be a long-running process (full
createrepo_c run, without --recycle-pkglist), and more, would be blocked
by other concurrent copr-repo processes (so it would be eventually
killed by timeout -> the build would continue -> and it would fail
anyways - regardless of the actual mock results, issue #1222). This
race should be closed now.
Also, stop running copr-repo before build is started (again), and "only"
wait till the repodata become available (and fail if they won't, after
certain time period). We used to have problems with this approach
before -- but we did not fail the builds, but rather kept waiting
indefinitely. Neither approach is ideal, but with the current approach
we should better motivate people to report issues.
Also move the logic out from BuildDispatcher to Worker so we never block
other builds by those checks.
Fixes: #1222