mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-04 03:08:21 +08:00
Use module.transition to change states.
This commit is contained in:
4
rida.py
4
rida.py
@@ -113,7 +113,7 @@ def submit_build():
|
||||
|
||||
def failure(message, code):
|
||||
# TODO, we should make some note of why it failed in a log...
|
||||
module.state = rida.database.BUILD_STATES["failed"]
|
||||
module.transition(rida.database.BUILD_STATES["failed"])
|
||||
db.session.add(module)
|
||||
db.session.commit()
|
||||
return message, code
|
||||
@@ -137,7 +137,7 @@ def submit_build():
|
||||
build = rida.database.ComponentBuild(module_id=module.id, package=pkgname, format="rpms")
|
||||
db.session.add(build)
|
||||
module.modulemd = mmd.dumps()
|
||||
module.state = rida.database.BUILD_STATES["wait"]
|
||||
module.transition(rida.database.BUILD_STATES["wait"])
|
||||
db.session.add(module)
|
||||
db.session.commit()
|
||||
# Publish to whatever bus we're configured to connect to.
|
||||
|
||||
@@ -38,6 +38,9 @@ from sqlalchemy.orm import (
|
||||
)
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Just like koji.BUILD_STATES, except our own codes for modules.
|
||||
BUILD_STATES = {
|
||||
@@ -143,6 +146,12 @@ class ModuleBuild(Base):
|
||||
raise ValueError("%r is not a module message." % msg['topic'])
|
||||
return session.query(cls).filter(cls.id==msg['msg']['id']).one()
|
||||
|
||||
def transition(self, state):
|
||||
""" Record that a build has transitioned state. """
|
||||
old_state = self.state
|
||||
self.state = state
|
||||
log.debug("%r, state %r->%r" % (old_state, self.state))
|
||||
|
||||
def json(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
|
||||
@@ -55,8 +55,8 @@ def init(config, session, msg):
|
||||
# TODO submit build from srpm to koji
|
||||
# TODO: buildroot.add_artifact(build_with_dist_tags)
|
||||
# TODO: buildroot.ready(artifact=$artifact)
|
||||
build.state = "wait" # Wait for the buildroot to be ready.
|
||||
log.debug("Done with init")
|
||||
build.transition(state="build") # Wait for the buildroot to be ready.
|
||||
session.commit()
|
||||
|
||||
|
||||
def build(config, session, msg):
|
||||
@@ -80,4 +80,5 @@ def build(config, session, msg):
|
||||
component_build.task = builder.build(artifact_name, scmurl)
|
||||
component_build.state = koji.BUILD_STATES['BUILDING']
|
||||
|
||||
build.state = "build" # Now wait for all of those to finish.
|
||||
build.transition(state="build") # Now wait for all of those to finish.
|
||||
session.commit()
|
||||
|
||||
Reference in New Issue
Block a user