mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 03:38:12 +08:00
Record components through the backend after module submission
This commit is contained in:
@@ -110,7 +110,8 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer):
|
||||
koji.BUILD_STATES["DELETED"]: NO_OP,
|
||||
}
|
||||
self.on_module_change = {
|
||||
models.BUILD_STATES["init"]: NO_OP,
|
||||
models.BUILD_STATES[
|
||||
"init"]: module_build_service.scheduler.handlers.modules.init,
|
||||
models.BUILD_STATES[
|
||||
"wait"]: module_build_service.scheduler.handlers.modules.wait,
|
||||
models.BUILD_STATES["build"]: NO_OP,
|
||||
|
||||
@@ -30,7 +30,9 @@ import module_build_service.utils
|
||||
import module_build_service.messaging
|
||||
from module_build_service.utils import (
|
||||
attempt_to_reuse_all_components,
|
||||
record_component_builds,
|
||||
get_rpm_release_from_mmd)
|
||||
from module_build_service.errors import UnprocessableEntity
|
||||
from module_build_service.builder.KojiContentGenerator import KojiContentGenerator
|
||||
|
||||
from requests.exceptions import ConnectionError
|
||||
@@ -122,6 +124,26 @@ def done(config, session, msg):
|
||||
build_logs.stop(build.id)
|
||||
|
||||
|
||||
def init(config, session, msg):
|
||||
""" Called whenever a module enters the 'init' state."""
|
||||
build = models.ModuleBuild.from_module_event(session, msg)
|
||||
|
||||
build.transition(config, "init", state_reason="Checking out the module components")
|
||||
session.add(build)
|
||||
session.commit()
|
||||
|
||||
try:
|
||||
mmd = build.mmd()
|
||||
record_component_builds(mmd, build, session=session)
|
||||
build.modulemd = mmd.dumps()
|
||||
build.transition(conf, models.BUILD_STATES["wait"])
|
||||
except UnprocessableEntity:
|
||||
build.transition(conf, models.BUILD_STATES["failed"])
|
||||
finally:
|
||||
session.add(build)
|
||||
session.commit()
|
||||
|
||||
|
||||
def wait(config, session, msg):
|
||||
""" Called whenever a module enters the 'wait' state.
|
||||
|
||||
|
||||
@@ -760,6 +760,13 @@ def format_mmd(mmd, scmurl, session=None):
|
||||
raise UnprocessableEntity(err_msg)
|
||||
|
||||
|
||||
def validate_mmd(mmd):
|
||||
for modname, mod in mmd.components.modules.items():
|
||||
if mod.repository and not conf.modules_allow_repository:
|
||||
raise Forbidden(
|
||||
"Custom component repositories aren't allowed")
|
||||
|
||||
|
||||
def merge_included_mmd(mmd, included_mmd):
|
||||
"""
|
||||
Merges two modulemds. This merges only metadata which are needed in
|
||||
@@ -938,10 +945,8 @@ def submit_module_build(username, url, mmd, scm, yaml, optional_params=None):
|
||||
**(optional_params or {})
|
||||
)
|
||||
|
||||
record_component_builds(mmd, module)
|
||||
|
||||
validate_mmd(mmd)
|
||||
module.modulemd = mmd.dumps()
|
||||
module.transition(conf, models.BUILD_STATES["wait"])
|
||||
db.session.add(module)
|
||||
db.session.commit()
|
||||
log.info("%s submitted build of %s, stream=%s, version=%s", username,
|
||||
|
||||
Reference in New Issue
Block a user