mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-07-16 11:02:02 +08:00
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:
@@ -0,0 +1,23 @@
|
||||
"""add reused_module_id column
|
||||
|
||||
Revision ID: 40b2c7d988d7
|
||||
Revises: bf861b6af29a
|
||||
Create Date: 2019-06-21 13:41:06.041269
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '40b2c7d988d7'
|
||||
down_revision = 'bf861b6af29a'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('module_builds', sa.Column('reused_module_id', sa.Integer(), nullable=True))
|
||||
sa.ForeignKeyConstraint(['reused_module_id'], ['module_builds.id'], ),
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('module_builds', 'reused_module_id')
|
||||
@@ -221,6 +221,8 @@ class ModuleBuild(MBSBase):
|
||||
rebuild_strategy = db.Column(db.String, nullable=False)
|
||||
virtual_streams = db.relationship(
|
||||
"VirtualStream", secondary=module_builds_to_virtual_streams, back_populates="module_builds")
|
||||
reused_module_id = db.Column(db.Integer, db.ForeignKey("module_builds.id"))
|
||||
reused_module = db.relationship("ModuleBuild", remote_side="ModuleBuild.id")
|
||||
|
||||
# List of arches against which the module is built.
|
||||
# NOTE: It is not filled for imported modules, because imported module builds have not been
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user