#365 Fix rawhide_to_release command
Merged 5 years ago by clime. Opened 5 years ago by frostyx.
copr/ frostyx/copr fix-rawhide-to-release  into  master

file modified
+4 -3
@@ -311,13 +311,14 @@ 

      def handle_rawhide_to_release(self, result):

          data = json.loads(self.data["data"])

          try:

-             chrootdir = os.path.join(self.opts.destdir, data["user"], data["copr"], data["dest_chroot"])

+             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)

                  os.makedirs(chrootdir)

  

              for build in data["builds"]:

-                 srcdir = os.path.join(self.opts.destdir, data["user"], data["copr"], data["rawhide_chroot"], build)

+                 srcdir = os.path.join(self.opts.destdir, data["ownername"],

+                                       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)
@@ -438,7 +439,7 @@ 

  

      def run(self):

          """ Handle action (other then builds) - like rename or delete of project """

-         self.log.info("Executing: %s", self)

+         self.log.info("Executing: %s", str(self))

  

          result = Munch()

          result.id = self.data["id"]

@@ -166,8 +166,8 @@ 

  

              self.turn_on_the_chroot_for_copr(copr, rawhide_chroot, mock_chroot)

  

-             data = {"copr": copr.name,

-                     "user": copr.user.name,

+             data = {"projectname": copr.name,

+                     "ownername": copr.owner_name,

                      "rawhide_chroot": rawhide_chroot,

                      "dest_chroot": dest_chroot,

                      "builds": []}
@@ -180,7 +180,7 @@ 

                      if not rbc or rbc.status != StatusEnum("succeeded"):

                          continue

  

-                     data["builds"].append(build.result_dir)

+                     data["builds"].append(rbc.result_dir)

  

                      if rbc and not dbc:

                          dest_build_chroot = models.BuildChroot(**rbc.to_dict())

Our rawhide_to_release command stopped working after b15e450.

That commit changed action data, that is sent to the backend.
It used to send build results dirs, that were constructed from build ID and package name.
b15e450 changed it and from that point, the sent result dirs are just build IDs.
However, backend data structure didn't change and neither the backend code.

This PR restores this particular behavior previous to the noted commit.

Also, a69a743 somehow messed with ownername and projectname attributes.
We can't just send copr.user.name because data for group projects are stored
in @group/project directories. And finally, I believe, that ownername and projectname
are better names than user and copr, because they are more explicit.

I can not test, but it looks sane. I wish such nice commit messages were a standard!

This bug is related: https://bugzilla.redhat.com/show_bug.cgi?id=1617918

It's better to simply use rbc.result_dir here where the build_dir name in the chroot is actually stored (e.g. 00788523-kernel). You don't need to add a new function then, just read the attribute.

You are right. It somehow doesn't work on my dev env, because both build.result_dir and rbc.result_dir are '' here. Maybe I should update or reinstall the stack. Looking into copr-fe-dev database, the rbc.result_dir should have the correct value. I will use it.

1 new commit added

  • [frontend] use rbc.result_dir instead, it has the exactly same value
5 years ago

Pull-Request has been merged by clime

5 years ago