Freshmaker is a service which:
See the docs for additional information.
Freshmaker waits for new fedmsg messages about artifact being updated,
this happens in consumer.py
. Every fedmsg message handled by a Freshmaker
is parsed by one of the parsers which can be found in the parsers
directory.
This parser converts the fedmsg to Event
object (inherits from BaseEvent
).
All the events are defined in the events.py
.
This Event object is then handled by one or more handlers defined
in the handlers
directory.
The handlers typically do following:
Most of the common tasks for handlers are already implemented in Freshmaker including:
The handler which rebuilds all the images that contain packages affected by CVEs in advisory when the advisory is shipped can look like this (only sample code for demonstration):
class RebuildImagesOnRPMAdvisoryChange(ContainerBuildHandler): name = 'RebuildImagesOnRPMAdvisoryChange' def can_handle(self, event): if not isinstance(event, ErrataAdvisoryRPMsSignedEvent): return False return True def handle(self, event): self.event = event db_event = Event.get_or_create_from_event(db.session, event) db.session.commit() # Check if we are allowed to build this advisory. if not self.event.is_allowed(self): db_event.transition( EventState.SKIPPED, f"Advisory {event.advisory.errata_id} is not allowed") db.session.commit() return [] # Get and record all images to rebuild batches = self._find_images_to_rebuild(db_event.search_key) builds = self._record_batches(batches, event) self.start_to_build_images(db_event.get_image_builds_in_first_batch(db.session)) db_event.transition(EventState.BUILDING, msg) return []
Create and activate a Python virtual environment.
Install the dependencies with:
python3 setup.py develop
Install the requirements:
pip3 install -r requirements.txt
Install the requirements useful to run the tests:
pip3 install -r test-requirements.txt
Run the tests:
pytest tests/