#352 Include full RPM manifest in unpublished images, so we can generate extra ODCS compose with them.
Merged 6 months ago by jkaluza. Opened 6 months ago by jkaluza.
jkaluza/freshmaker factory-3771  into  master

file modified
+19 -3

@@ -502,12 +502,25 @@ 

          # Get the published version of this image to find out if the image

          # was actually published.

          images = lb_instance.get_images_by_nvrs(

-             [self["brew"]["build"]], published=True)

+             [self["brew"]["build"]], published=True, include_rpms=False)

          if images:

              self["published"] = True

          else:

              self["published"] = False

  

+             # Usually we do not store complete RPM manifest, but when

+             # image is unpublished, we need complete RPM manifest in order

+             # to check for possible unpublished RPMs.

+             # We do not want to get the complete manifest for every container

+             # image, because it is relatively big, so fetch it only when needed.

+             images = lb_instance.get_images_by_nvrs(

+                 [self["brew"]["build"]])

+             if images:

+                 self["rpm_manifest"] = images[0]["rpm_manifest"]

+             else:

+                 log.warning("No image %s found in Lightblue.",

+                             self["brew"]["build"])

+ 

      def resolve(self, lb_instance, children=None):

          """

          Resolves the Container image - populates additional metadata by

@@ -918,7 +931,7 @@ 

          return images

  

      def get_images_by_nvrs(self, nvrs, published=True, content_sets=None,

-                            srpm_nvrs=None):

+                            srpm_nvrs=None, include_rpms=True):

          """Query lightblue and returns containerImages defined by list of

          `nvrs`.

  

@@ -927,6 +940,8 @@ 

          :param list content_sets: List of content_sets the image includes RPMs

              from.

          :param list srpm_nvrs: list of SRPM NVRs to look for

+         :param bool include_rpms: When True, the rpm_manifest is included in

+             the returned ContainerImages.

          :return: List of containerImages.

          :rtype: list of ContainerImages.

          """

@@ -948,7 +963,8 @@ 

                      },

                  ]

              },

-             "projection": self._get_default_projection()

+             "projection": self._get_default_projection(

+                 include_rpms=include_rpms)

          }

  

          if content_sets is not None:

file modified
+20 -2

@@ -535,7 +535,8 @@ 

          image.resolve_published(lb)

          self.assertEqual(image["published"], True)

          lb.get_images_by_nvrs.assert_called_once_with(

-             ["package-name-1-4-12.10"], published=True)

+             ["package-name-1-4-12.10"], published=True,

+             include_rpms=False)

  

      def test_resolve_published_unpublished(self):

          image = ContainerImage.create({

@@ -546,9 +547,26 @@ 

          })

  

          lb = Mock()

-         lb.get_images_by_nvrs.return_value = []

+         lb.get_images_by_nvrs.side_effect = [[], [{"rpm_manifest": "x"}]]

          image.resolve_published(lb)

          self.assertEqual(image["published"], False)

+         lb.get_images_by_nvrs.asssert_has_calls([

+             call(["package-name-1-4-12.10"], published=True, include_rpms=False),

+             call(["package-name-1-4-12.10"])])

+ 

+         self.assertEqual(image["rpm_manifest"], "x")

+ 

+     def test_resolve_published_not_image_in_lb(self):

+         image = ContainerImage.create({

+             '_id': '1233829',

+             'brew': {

+                 'build': 'package-name-1-4-12.10',

+             },

+         })

+ 

+         lb = Mock()

+         lb.get_images_by_nvrs.return_value = []

+         image.resolve_published(lb)

  

  

  class TestContainerRepository(helpers.FreshmakerTestCase):

Usually we do not store complete RPM manifest, but when
image is unpublished, we need complete RPM manifest in order
to check for possible unpublished RPMs.

We do not want to get the complete manifest for every container
image, because it is relatively big, so fetch it only when needed.

This PR depends on PR#351.

:thumbsup: after this is rebased because of #351. :-)

rebased onto 1fdf99d

6 months ago

Pull-Request has been merged by jkaluza

6 months ago