#379 Rebuild also for tech preview and beta images
Merged 5 years ago by jkaluza. Opened 5 years ago by ralph.
ralph/freshmaker also-tech-preview  into  master

@@ -370,13 +370,13 @@ 

                         private_key=conf.lightblue_private_key)

  

          # Check if we are allowed to rebuild unpublished images and clear

-         # published and release_category if so.

+         # published and release_categories if so.

          if self.event.is_allowed(self, published=True):

              published = True

-             release_category = "Generally Available"

+             release_categories = ("Generally Available", "Tech Preview", "Beta",)

          else:

              published = None

-             release_category = None

+             release_categories = None

  

          # Limit the Lightblue query to particular leaf images if set in Event.

          leaf_container_images = None
@@ -392,6 +392,6 @@ 

          batches = lb.find_images_to_rebuild(

              srpm_nvrs, content_sets,

              filter_fnc=self._filter_out_not_allowed_builds,

-             published=published, release_category=release_category,

+             published=published, release_categories=release_categories,

              leaf_container_images=leaf_container_images)

          return batches

file modified
+22 -21
@@ -675,14 +675,14 @@ 

  

      def _set_container_repository_filters(

              self, request, published=True,

-             release_category="Generally Available"):

+             release_categories=("Generally Available", "Tech Preview", "Beta",)):

          """

          Sets the additional filters to containerRepository request

-         based on the self.published, self.release_category attributes.

+         based on the self.published, self.release_categories attributes.

          :param bool published: whether to limit queries to published

              repositories

-         :param str release_category: filter only repositories with specific

-             release category (options: Deprecated, Generally Available, Beta, Tech Preview)

+         :param tuple release_categories: filter only repositories with specific

+             release categories (options: Deprecated, Generally Available, Beta, Tech Preview)

          """

          if published is not None:

              request["query"]["$and"].append({
@@ -691,25 +691,26 @@ 

                  "rvalue": published

              })

  

-         if release_category:

+         if release_categories:  # Check if release_categories is None or empty

              request["query"]["$and"].append({

                  "field": "release_categories.*",

-                 "op": "=",

-                 "rvalue": release_category

+                 "op": "$in",

+                 "rvalue": release_categories,

              })

  

          return request

  

      def find_all_container_repositories(

-             self, published=True, release_category="Generally Available"):

+             self, published=True,

+             release_categories=("Generally Available", "Tech Preview", "Beta",)):

          """

          Returns dict with repository name as key and ContainerRepository as

          value.

  

          :param bool published: whether to limit queries to published

              repositories

-         :param str release_category: filter only repositories with specific

-             release category (options: Deprecated, Generally Available, Beta,

+         :param tuple release_categories: filter only repositories with specific

+             release categories (options: Deprecated, Generally Available, Beta,

              Tech Preview)

          :rtype: dict

          :return: Dict with repository name as key and ContainerRepository as
@@ -726,7 +727,7 @@ 

              ]

          }

          repo_request = self._set_container_repository_filters(

-             repo_request, published, release_category)

+             repo_request, published, release_categories)

          repositories = self.find_container_repositories(repo_request)

          return {r["repository"]: r for r in repositories}

  
@@ -1201,8 +1202,8 @@ 

              images.append(image)

  

      def find_images_with_packages_from_content_set(

-             self, srpm_nvrs, content_sets, filter_fnc=None,

-             published=True, release_category="Generally Available",

+             self, srpm_nvrs, content_sets, filter_fnc=None, published=True,

+             release_categories=("Generally Available", "Tech Preview", "Beta",),

              leaf_container_images=None):

          """Query lightblue and find containers which contain given

          package from one of content sets
@@ -1218,8 +1219,8 @@ 

              Freshmaker configuration.

          :param bool published: whether to limit queries to published

              repositories

-         :param str release_category: filter only repositories with specific

-             release category (options: Deprecated, Generally Available, Beta, Tech Preview)

+         :param str release_categories: filter only repositories with specific

+             release categories (options: Deprecated, Generally Available, Beta, Tech Preview)

          :param list leaf_container_images: List of NVRs of leaf images to

              consider for the rebuild. If not set, all images found in

              Lightblue will be considered for rebuild.
@@ -1231,7 +1232,7 @@ 

              the given image - can be used for comparisons if needed

          :rtype: list

          """

-         repos = self.find_all_container_repositories(published, release_category)

+         repos = self.find_all_container_repositories(published, release_categories)

          if not repos:

              return []

          if not leaf_container_images:
@@ -1491,8 +1492,8 @@ 

  

      def find_images_to_rebuild(

              self, srpm_nvrs, content_sets, published=True,

-             release_category="Generally Available", filter_fnc=None,

-             leaf_container_images=None):

+             release_categories=("Generally Available", "Tech Preview", "Beta",),

+             filter_fnc=None, leaf_container_images=None):

          """

          Find images to rebuild through image build layers

  
@@ -1507,8 +1508,8 @@ 

              when looking for the packages

          :param bool published: whether to limit queries to published

              repositories

-         :param str release_category: filter only repositories with specific

-             release category (options: Deprecated, Generally Available, Beta, Tech Preview)

+         :param tuple release_categories: filter only repositories with specific

+             release categories (options: Deprecated, Generally Available, Beta, Tech Preview)

          :param function filter_fnc: Function called as

              filter_fnc(container_image) with container_image being

              ContainerImage instance. If this function returns True, the image
@@ -1522,7 +1523,7 @@ 

          """

          images = self.find_images_with_packages_from_content_set(

              srpm_nvrs, content_sets, filter_fnc, published,

-             release_category, leaf_container_images=leaf_container_images)

+             release_categories, leaf_container_images=leaf_container_images)

  

          srpm_names = [koji.parse_NVR(srpm_nvr)["name"] for srpm_nvr in srpm_nvrs]

  

@@ -439,7 +439,7 @@ 

          self.find_images_to_rebuild.assert_called_once_with(

              set(['httpd-2.4-11.el7']), ['content-set-1'],

              filter_fnc=self.handler._filter_out_not_allowed_builds,

-             published=True, release_category='Generally Available',

+             published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'),

              leaf_container_images=None)

  

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={
@@ -456,7 +456,7 @@ 

          self.find_images_to_rebuild.assert_called_once_with(

              set(['httpd-2.4-11.el7', 'httpd-2.2-11.el6']), ['content-set-1'],

              filter_fnc=self.handler._filter_out_not_allowed_builds,

-             published=True, release_category='Generally Available',

+             published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'),

              leaf_container_images=None)

  

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={
@@ -475,7 +475,7 @@ 

          self.find_images_to_rebuild.assert_called_once_with(

              set(['httpd-2.4-11.el7']), ['content-set-1'],

              filter_fnc=self.handler._filter_out_not_allowed_builds,

-             published=None, release_category=None,

+             published=None, release_categories=None,

              leaf_container_images=None)

  

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={
@@ -492,7 +492,7 @@ 

          self.find_images_to_rebuild.assert_called_once_with(

              set(['httpd-2.4-11.el7']), ['content-set-1'],

              filter_fnc=self.handler._filter_out_not_allowed_builds,

-             published=True, release_category='Generally Available',

+             published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'),

              leaf_container_images=None)

  

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={
@@ -510,5 +510,5 @@ 

          self.find_images_to_rebuild.assert_called_once_with(

              set(['httpd-2.4-11.el7']), ['content-set-1'],

              filter_fnc=self.handler._filter_out_not_allowed_builds,

-             published=True, release_category='Generally Available',

+             published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'),

              leaf_container_images=["foo", "bar"])

file modified
+3 -3
@@ -924,9 +924,9 @@ 

                      },

                      {

                          "field": "release_categories.*",

-                         "op": "=",

-                         "rvalue": "Generally Available"

-                     }

+                         "op": "$in",

+                         "rvalue": ("Generally Available", "Tech Preview", "Beta"),

+                     },

                  ]

              },

              "projection": [

I'm OK with merging that and testing on dev instance, but I want to wait for @lucarval to sync up with me after my PTO to find out if we really want to rebuild TP/Beta images.

Ack, :+1:. This will be news to him too - so, let's have a conversation. :)

There's also possible issue in case then there are "foo-1-1" released and "Generally Available" and there is new "foo-1-2" (the same major, but different minor version) marked TP or Beta. In that case, Freshmaker would consider only the foo-1-2 for the rebuild...

Not sure if that can happen.

Pull-Request has been merged by jkaluza

5 years ago