#353 Bob: Add rebuilt repository names into DB as ArtifactBuilds.
Merged 3 months ago by jkaluza. Opened 3 months ago by jkaluza.
jkaluza/freshmaker bob  into  master

@@ -267,8 +267,11 @@ 

          :rtype: ArtifactBuild.

          """

  

-         ev = models.Event.get_or_create(db.session, event.msg_id,

-                                         event.search_key, event.__class__)

+         if isinstance(event, models.Event):

+             ev = event

+         else:

+             ev = models.Event.get_or_create(

+                 db.session, event.msg_id, event.search_key, event.__class__)

          build = models.ArtifactBuild.create(db.session, ev, name,

                                              artifact_type.name.lower(),

                                              build_id, dep_on, state,

@@ -29,7 +29,7 @@ 

  from freshmaker.pulp import Pulp

  from freshmaker.events import ErrataAdvisoryStateChangedEvent

  from freshmaker.handlers import ContainerBuildHandler, fail_event_on_handler_exception

- from freshmaker.types import EventState

+ from freshmaker.types import EventState, ArtifactType, ArtifactBuildState

  

  

  class RebuildImagesOnImageAdvisoryChange(ContainerBuildHandler):

@@ -94,6 +94,14 @@ 

          # Submit rebuild request to Bob :).

          for repo_name in docker_repos.keys():

              self.log_info("Requesting Bob rebuild of %s", repo_name)

+ 

+             # TODO: The Bob API does not return any useful data, so just mark

+             # the rebuild as "DONE". If there will be some state sent by

+             # the API, we could set the build state according to it.

+             build = self.record_build(

+                 db_event, repo_name, ArtifactType.IMAGE,

+                 state=ArtifactBuildState.DONE.value)

+ 

              bob_url = "%s/update_children/%s" % (

                  conf.bob_server_url.rstrip('/'), repo_name)

              headers = {"Authorization": "Bearer %s" % conf.bob_auth_token}

@@ -26,6 +26,7 @@ 

  from freshmaker.errata import ErrataAdvisory

  from freshmaker.events import ErrataAdvisoryStateChangedEvent

  from freshmaker.handlers.bob import RebuildImagesOnImageAdvisoryChange

+ from freshmaker import models, db

  from tests import helpers

  

  

@@ -40,7 +41,10 @@ 

                             security_impact="",

                             product_short_name="product"))

          self.handler = RebuildImagesOnImageAdvisoryChange()

-         self.db_event = MagicMock()

+         self.db_event = models.Event.get_or_create(

+             db.session, self.event.msg_id, self.event.search_key,

+             self.event.__class__)

+ 

  

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={

          'RebuildImagesOnImageAdvisoryChange': {

@@ -84,6 +88,11 @@ 

              'http://localhost/update_children/scl/bar-526',

              headers={'Authorization': 'Bearer x'})

  

+         self.assertEqual(self.db_event.state, models.EventState.COMPLETE.value)

+ 

+         builds = set([b.name for b in self.db_event.builds])

+         self.assertEqual(builds, set(['scl/foo-526', 'scl/bar-526']))

+ 

      @patch("freshmaker.errata.Errata.get_docker_repo_tags")

      @patch("freshmaker.pulp.Pulp.get_docker_repository_name")

      @patch("freshmaker.handlers.bob."

This makes it clear from the Freshmaker API what repositories have been
rebuilt in Bob.

Commit 18f639f fixes this pull-request

Pull-Request has been merged by jkaluza

3 months ago

Pull-Request has been merged by jkaluza

3 months ago