#398 Reuse "complete" ArtifactBuilds from original Event
Merged by jkaluza. Opened by gnaponie.
gnaponie/freshmaker FACTORY-4672  into  master

Download 398.patch

When some parent image in the current Event has the same
original_nvr as the completely built image in the previous Event,
then the current parent image should be replaced by the
rebuild_nvr from the original event.
ref. FACTORY-4672

Signed-off-by: gnaponie gnaponie@redhat.com

@jkaluza can you please check? Are the conditions of the test sufficient?
cc. @yashn

We have discussed this on IRC, no need for further reviews right now.

Small issue with current implementation is that the ArtifactBuild representing the parent_nvr in the db_event stays in the db_event even when it is reused and nothing is really built against it. Giulia will work on fix and update the PR after that.

rebased onto 1a6d65c99ba24b5cdaa923f789f3f2a8b6a7f600

rebased onto 831796fdab33718dab4e3b3d34561b7fbf6f2567

rebased onto aa00de9684a3a63f2912db6c69a18d4f0998e536

@jkaluza I think it's complete now. PTAL

rebased onto 8db5830142a6a6e178731a2ebbf805fb060a075e

Suggestion: Consider implementing this logic in Event class directly to avoid code duplication:

class Event(FreshmakerBase):
  ...
  def get_artifact_build_from_event_dependencies(self, session, nvr):
    for parent_event in self.event_dependencies:
      ...
      return parent_build
    return None  # Implicitly

Why do we need to query the database again?

Why do we need to query the database again?

Ah! It's because we query with the nvr, then parent_nvr.

+1, can you do it this way @giulia?

I will let the apprentice to answer that :-P.

@lucarval The first query handles the fact that the original parent should not be created at all. The second part of the part changes how the child image gets created.
Without the first part we are still creating the parent, that would still be built by Freshmaker even if it's not necessary, because there's no child depending on it.

@jkaluza are you satisfied with the apprentice reply? :D

rebased onto 312b2103ce2ecee60796a9f45b4ce0bd2377ace3

@jkaluza @lucarval I've rebased with the suggestion. Could make another review? Thanks.

Add docstring please stating that nvr is used as original_nvr when finding the ArtifactBuild.

rebased onto 8e7149d5fb15cb5020cf461a0ce96373b729ab1b

Commit 0c4b8cb4 fixes this pull-request

Pull-Request has been merged by jkaluza

Pull-Request has been merged by jkaluza

Metadata