Make sure builds are queued under a transaction. This should prevent a queue item from existing without its repository build object (or vice versa).
This commit is contained in:
parent
8b331b453e
commit
208c97776f
1 changed files with 11 additions and 9 deletions
|
@ -10,6 +10,7 @@ from flask.ext.principal import identity_changed
|
||||||
from random import SystemRandom
|
from random import SystemRandom
|
||||||
|
|
||||||
from data import model
|
from data import model
|
||||||
|
from data.database import db
|
||||||
from app import app, login_manager, dockerfile_build_queue, notification_queue
|
from app import app, login_manager, dockerfile_build_queue, notification_queue
|
||||||
from auth.permissions import QuayDeferredPermissionUser
|
from auth.permissions import QuayDeferredPermissionUser
|
||||||
from auth import scopes
|
from auth import scopes
|
||||||
|
@ -222,16 +223,17 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
||||||
'build_subdir': subdir
|
'build_subdir': subdir
|
||||||
}
|
}
|
||||||
|
|
||||||
build_request = model.create_repository_build(repository, token, job_config,
|
with app.config['DB_TRANSACTION_FACTORY'](db):
|
||||||
dockerfile_id, build_name,
|
build_request = model.create_repository_build(repository, token, job_config,
|
||||||
trigger, pull_robot_name=pull_robot_name)
|
dockerfile_id, build_name,
|
||||||
|
trigger, pull_robot_name=pull_robot_name)
|
||||||
|
|
||||||
dockerfile_build_queue.put([repository.namespace_user.username, repository.name], json.dumps({
|
dockerfile_build_queue.put([repository.namespace_user.username, repository.name], json.dumps({
|
||||||
'build_uuid': build_request.uuid,
|
'build_uuid': build_request.uuid,
|
||||||
'namespace': repository.namespace_user.username,
|
'namespace': repository.namespace_user.username,
|
||||||
'repository': repository.name,
|
'repository': repository.name,
|
||||||
'pull_credentials': model.get_pull_credentials(pull_robot_name) if pull_robot_name else None
|
'pull_credentials': model.get_pull_credentials(pull_robot_name) if pull_robot_name else None
|
||||||
}), retries_remaining=1)
|
}), retries_remaining=1)
|
||||||
|
|
||||||
# Add the build to the repo's log.
|
# Add the build to the repo's log.
|
||||||
metadata = {
|
metadata = {
|
||||||
|
|
Reference in a new issue