Skip to content

Commit

Permalink
backend: multiple attempts to create repository before giving up
Browse files Browse the repository at this point in the history
See #3016

Also, we are now logging exceptions
  • Loading branch information
FrostyX authored and praiskup committed Apr 29, 2024
1 parent e4c9e80 commit 0e1c549
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions backend/copr_backend/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ class RawhideToRelease(Action):
def run(self):
data = json.loads(self.data["data"])
appstream = data["appstream"]
result = BackendResultEnum("success")
try:
chrootdir = os.path.join(self.opts.destdir, data["ownername"],
data["copr_dir"], data["dest_chroot"])
Expand All @@ -444,13 +443,20 @@ def run(self):
copy_function=copy2_but_hardlink_rpms)
with open(os.path.join(destdir, "build.info"), "a") as f:
f.write("\nfrom_chroot={}".format(data["rawhide_chroot"]))
return self._createrepo_repeatedly(chrootdir, appstream)

if not call_copr_repo(chrootdir, appstream=appstream, logger=self.log):
result = BackendResultEnum("failure")
except:
result = BackendResultEnum("failure")
# pylint: disable=broad-except
except Exception:
self.log.exception("Unexpected error when forking from rawhide")
return BackendResultEnum("failure")

return result
def _createrepo_repeatedly(self, chrootdir, appstream):
for i in range(5):
if call_copr_repo(chrootdir, appstream=appstream, logger=self.log):
return BackendResultEnum("success")
self.log.error("Createrepo failed, trying again #%s", i)
time.sleep(10)
return BackendResultEnum("failure")


class BuildModule(Action):
Expand Down

0 comments on commit 0e1c549

Please sign in to comment.