From 8bffc6a7500adbd9c0d88d7d2fd5e3d162c39f4a Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 24 2020 11:39:48 +0000 Subject: [PATCH 1/5] frontend: fix rawihde to release Inherit result_dir from BuildChroot, not Build. The rawhide_to_release actions generated before were wrong (but safe) and could not work. Fixes bug caused by 76dbc56902cb8ced49f85b29d92ce5ab95296895. --- diff --git a/frontend/coprs_frontend/commands/rawhide_to_release.py b/frontend/coprs_frontend/commands/rawhide_to_release.py index 3f0c9df..0ebb335 100644 --- a/frontend/coprs_frontend/commands/rawhide_to_release.py +++ b/frontend/coprs_frontend/commands/rawhide_to_release.py @@ -95,7 +95,8 @@ def rawhide_to_release_function(rawhide_chroot, dest_chroot): dest_build_chroot.status = StatusEnum("forked") db.session.add(dest_build_chroot) - data['builds'].append(build.result_dir) + if rbc.result_dir: + data['builds'].append(rbc.result_dir) if len(data["builds"]): actions_logic.ActionsLogic.send_rawhide_to_release(data) From a332f1fa1efeacb6b2e648f517ae313a7b956a2b Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 24 2020 11:39:48 +0000 Subject: [PATCH 2/5] backend: more verbose rawhide to release action processing --- diff --git a/backend/backend/actions.py b/backend/backend/actions.py index 24aaf3b..7730cb5 100644 --- a/backend/backend/actions.py +++ b/backend/backend/actions.py @@ -347,7 +347,7 @@ class Action(object): try: chrootdir = os.path.join(self.opts.destdir, data["ownername"], data["projectname"], data["dest_chroot"]) if not os.path.exists(chrootdir): - self.log.debug("Create directory: %s", chrootdir) + self.log.info("Create directory: %s", chrootdir) os.makedirs(chrootdir) for build in data["builds"]: @@ -355,7 +355,7 @@ class Action(object): data["projectname"], data["rawhide_chroot"], build) if os.path.exists(srcdir): destdir = os.path.join(chrootdir, build) - self.log.debug("Copy directory: %s as %s", srcdir, destdir) + self.log.info("Copy directory: %s as %s", srcdir, destdir) shutil.copytree(srcdir, destdir) with open(os.path.join(destdir, "build.info"), "a") as f: From db054c844dd99fd79402f00382ffd578f6f0d53d Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 24 2020 11:39:48 +0000 Subject: [PATCH 3/5] frontend: allow repeated run of 'rawhide-to-release' Previously we silently skipped those projects that were already run. --- diff --git a/frontend/coprs_frontend/commands/rawhide_to_release.py b/frontend/coprs_frontend/commands/rawhide_to_release.py index 0ebb335..250718b 100644 --- a/frontend/coprs_frontend/commands/rawhide_to_release.py +++ b/frontend/coprs_frontend/commands/rawhide_to_release.py @@ -79,21 +79,20 @@ def rawhide_to_release_function(rawhide_chroot, dest_chroot): continue for build in fork_builds: - if mock_chroot in build.chroots: - # forked chroot already exists, from previous run? - continue - # rbc means rawhide_build_chroot (we needed short variable) rbc = None for rbc in build.build_chroots: if rbc.mock_chroot == mock_rawhide_chroot: break - dest_build_chroot = models.BuildChroot(**rbc.to_dict()) - dest_build_chroot.mock_chroot_id = mock_chroot.id - dest_build_chroot.mock_chroot = mock_chroot - dest_build_chroot.status = StatusEnum("forked") - db.session.add(dest_build_chroot) + if mock_chroot not in build.chroots: + # forked chroot may already exists, e.g. from prevoius + # 'rawhide-to-release-run' + dest_build_chroot = models.BuildChroot(**rbc.to_dict()) + dest_build_chroot.mock_chroot_id = mock_chroot.id + dest_build_chroot.mock_chroot = mock_chroot + dest_build_chroot.status = StatusEnum("forked") + db.session.add(dest_build_chroot) if rbc.result_dir: data['builds'].append(rbc.result_dir) From 1a34b7c7113ccd8dc0c2e660552d97bf764f4774 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 24 2020 11:39:48 +0000 Subject: [PATCH 4/5] frontend: rawhide-to-release --retry-forked option Sometimes rawhide-to-release might go wrong, and we need to be able to re-submit the action. Previously we just silently skipped all the builds which were looking like forked. Now there's option --retry-forked which enforces (re-tries) forks on backend. --- diff --git a/frontend/coprs_frontend/commands/branch_fedora.py b/frontend/coprs_frontend/commands/branch_fedora.py index 31da536..31d06ac 100644 --- a/frontend/coprs_frontend/commands/branch_fedora.py +++ b/frontend/coprs_frontend/commands/branch_fedora.py @@ -11,10 +11,18 @@ from commands.rawhide_to_release import rawhide_to_release_function type=int ) @click.option( + "--retry-forked/--no-retry-forked", + default=False, + help=( + "Generate actions for backend also for already forked builds, useful " + "e.g. when previous run of this command failed." + ) +) +@click.option( "--dist-git-branch", "-b", "branch", help="Branch name for this set of new chroots" ) -def branch_fedora(fedora_version, branch=None): +def branch_fedora(fedora_version, retry_forked, branch=None): """ Branch fedora-rawhide-* chroots to fedora-N* and execute rawhide-to-release on them @@ -33,4 +41,4 @@ def branch_fedora(fedora_version, branch=None): create_chroot_function(chroot_pairs.keys(), branch, True) for new_chroot, rawhide_chroot in chroot_pairs.items(): - rawhide_to_release_function(rawhide_chroot, new_chroot) + rawhide_to_release_function(rawhide_chroot, new_chroot, retry_forked) diff --git a/frontend/coprs_frontend/commands/rawhide_to_release.py b/frontend/coprs_frontend/commands/rawhide_to_release.py index 250718b..7238ae1 100644 --- a/frontend/coprs_frontend/commands/rawhide_to_release.py +++ b/frontend/coprs_frontend/commands/rawhide_to_release.py @@ -17,13 +17,22 @@ from coprs.logic import coprs_logic, actions_logic, builds_logic, packages_logic "dest_chroot", required=True ) -def rawhide_to_release(rawhide_chroot, dest_chroot): +@click.option( + "--retry-forked/--no-retry-forked", + default=False, + help=( + "Generate actions for backend also for already forked builds, useful " + "e.g. when previous run of this command failed." + ) +) +def rawhide_to_release(rawhide_chroot, dest_chroot, retry_forked): """ Branching """ - return rawhide_to_release_function(rawhide_chroot, dest_chroot) + return rawhide_to_release_function(rawhide_chroot, dest_chroot, + retry_forked) -def rawhide_to_release_function(rawhide_chroot, dest_chroot): +def rawhide_to_release_function(rawhide_chroot, dest_chroot, retry_forked): mock_chroot = coprs_logic.MockChrootsLogic.get_from_name(dest_chroot).first() if not mock_chroot: print("Given chroot does not exist. Please run:") @@ -79,13 +88,19 @@ def rawhide_to_release_function(rawhide_chroot, dest_chroot): continue for build in fork_builds: + chroot_exists = mock_chroot in build.chroots + + if chroot_exists and not retry_forked: + # this build should already be forked + continue + # rbc means rawhide_build_chroot (we needed short variable) rbc = None for rbc in build.build_chroots: if rbc.mock_chroot == mock_rawhide_chroot: break - if mock_chroot not in build.chroots: + if not chroot_exists: # forked chroot may already exists, e.g. from prevoius # 'rawhide-to-release-run' dest_build_chroot = models.BuildChroot(**rbc.to_dict()) From 0a568515898a68d6582896bcaff888c1d5d49d83 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Feb 24 2020 11:39:48 +0000 Subject: [PATCH 5/5] frontend: rawhide_to_release should create the chroots deactivated Fixes: #1283 --- diff --git a/frontend/coprs_frontend/commands/branch_fedora.py b/frontend/coprs_frontend/commands/branch_fedora.py index 31d06ac..015029a 100644 --- a/frontend/coprs_frontend/commands/branch_fedora.py +++ b/frontend/coprs_frontend/commands/branch_fedora.py @@ -38,7 +38,7 @@ def branch_fedora(fedora_version, retry_forked, branch=None): for rch in rawhide_chroots } - create_chroot_function(chroot_pairs.keys(), branch, True) + create_chroot_function(chroot_pairs.keys(), branch, False) for new_chroot, rawhide_chroot in chroot_pairs.items(): rawhide_to_release_function(rawhide_chroot, new_chroot, retry_forked)