#1137 frontend: fix createrepo for pull-request copr-dirs
Merged 4 years ago by praiskup. Opened 4 years ago by praiskup.
Unknown source fix-pr-createrepo  into  master

@@ -5,6 +5,7 @@

  from coprs import db

  from coprs import models

  from coprs import helpers

+ from coprs import exceptions

  

  

  class ActionsLogic(object):
@@ -69,11 +70,25 @@

          db.session.add(action)

  

      @classmethod

-     def send_createrepo(cls, copr):

+     def send_createrepo(cls, copr, dirnames=None, main_only=True):

+         possible_dirnames = [copr_dir.name for copr_dir in copr.dirs

+                              if not main_only or copr_dir.main]

+ 

+         if not dirnames:

+             # by default we createrepo for all of them

+             dirnames = possible_dirnames

+         else:

+             missing = set(dirnames) - set(possible_dirnames)

+             if missing:

+                 # TODO: we should raise NotFoundException here

+                 #raise exceptions.NotFoundException(

+                 #    "Can't createrepo for {} in {}".format(

+                 #        missing, copr.full_name))

+                 pass

          data_dict = {

              "ownername": copr.owner_name,

              "projectname": copr.name,

-             "project_dirnames": [copr_dir.name for copr_dir in copr.dirs],

+             "project_dirnames": dirnames,

              "chroots": [chroot.name for chroot in copr.active_chroots],

          }

          action = models.Action(

@@ -526,6 +526,8 @@

          copr_dir = models.CoprDir(

              name=dirname, copr=copr, main=main)

  

+         ActionsLogic.send_createrepo(copr, dirnames=[dirname], main_only=False)

+ 

          db.session.add(copr_dir)

          return copr_dir

  
@@ -699,15 +701,15 @@

          current_chroots = copr.mock_chroots

          new_chroots = cls.mock_chroots_from_names(names)

          # add non-existing

-         run_createrepo = False

+         run_createrepo = []

          for mock_chroot in new_chroots:

              if mock_chroot not in current_chroots:

                  db.session.add(

                      models.CoprChroot(copr=copr, mock_chroot=mock_chroot))

-                 run_createrepo = True

+                 run_createrepo.append(mock_chroot.name)

  

          if run_createrepo:

-             ActionsLogic.send_createrepo(copr)

+             ActionsLogic.send_createrepo(copr, dirnames=run_createrepo)

  

          # delete no more present

          to_remove = []

We did not create action for createrepo when we created new CoprDir for
pull-request. This in turn caused that backend never took the build
task, because we implemented the wait-for-repo loop in commit
6cf66a9. So create the repository explicitly in
CoprDirsLogic.get_or_create() for now to work-around the problem.

This isn't really proper fix; we should bound the createrepo action with
any CoprDir creation, and create CoprDir automatically with new
CoprChroot instance. But it will require proper testing and I don't
have enough time before release.

Relates: #1135

rebased onto 224e65a4cb7322ec2bf29826ee6981edab52379d

4 years ago

rebased onto c28d2e64d9ecd57e26015ec216c0fa1eb4190489

4 years ago

Metadata Update from @praiskup:
- Pull-request tagged with: release-blocker

4 years ago

rebased onto 0242c13

4 years ago

Pull-Request has been merged by praiskup

4 years ago