Module builds now remember what module they reused for building.

There was a race condition, when 2 builds where build in the same time.
There was an issue that after one has finished the other reused the new build
for reuse and not the one it started with.

Ticket-ID: FACTORY-3862

Signed-off-by: Martin Curlej <mcurlej@redhat.com>
This commit is contained in:
Martin Curlej
2019-06-21 16:05:58 +02:00
parent e19c58b6ad
commit ed24ca870a
4 changed files with 74 additions and 1 deletions

View File

@@ -85,8 +85,11 @@ def get_reusable_module(session, module):
:param module: the ModuleBuild object of module being built.
:return: ModuleBuild object which can be used for component reuse.
"""
mmd = module.mmd()
if module.reused_module:
return module.reused_module
mmd = module.mmd()
# Find the latest module that is in the done or ready state
previous_module_build = (
session.query(models.ModuleBuild)
@@ -111,6 +114,9 @@ def get_reusable_module(session, module):
log.info("Cannot re-use. %r is the first module build." % module)
return None
module.reused_module_id = previous_module_build.id
session.commit()
return previous_module_build