mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
strict_module_state_transitions config option
Fixes: https://pagure.io/fm-orchestrator/issue/1678
This commit is contained in:
@@ -759,6 +759,11 @@ class Config(object):
|
||||
"default": False,
|
||||
"desc": "Whether to allow dashes in stream, version, and context values.",
|
||||
},
|
||||
"strict_module_state_transitions": {
|
||||
"type": bool,
|
||||
"default": True,
|
||||
"desc": "Whether to strictly enforce module state transitions",
|
||||
},
|
||||
}
|
||||
|
||||
def __init__(self, conf_section_obj):
|
||||
|
||||
@@ -61,8 +61,17 @@ def failed(msg_id, module_build_id, module_build_state):
|
||||
"Note that retrieved module state %r doesn't match message module state %r",
|
||||
build.state, module_build_state,
|
||||
)
|
||||
# This is ok.. it's a race condition we can ignore.
|
||||
pass
|
||||
|
||||
if conf.strict_module_state_transitions:
|
||||
valid_states = (
|
||||
models.BUILD_STATES["init"],
|
||||
models.BUILD_STATES["wait"],
|
||||
models.BUILD_STATES["build"],
|
||||
models.BUILD_STATES["failed"],
|
||||
)
|
||||
if build.state not in valid_states:
|
||||
log.error("Module failed handler called while module in state %r", build.state)
|
||||
return
|
||||
|
||||
if build.koji_tag:
|
||||
builder = GenericBuilder.create_from_module(db_session, build, conf)
|
||||
@@ -123,8 +132,15 @@ def done(msg_id, module_build_id, module_build_state):
|
||||
"Note that retrieved module state %r doesn't match message module state %r",
|
||||
build.state, module_build_state,
|
||||
)
|
||||
# This is ok.. it's a race condition we can ignore.
|
||||
pass
|
||||
|
||||
if conf.strict_module_state_transitions:
|
||||
valid_states = (
|
||||
models.BUILD_STATES["build"],
|
||||
models.BUILD_STATES["done"],
|
||||
)
|
||||
if build.state not in valid_states:
|
||||
log.error("Module done handler called while module in state %r", build.state)
|
||||
return
|
||||
|
||||
# Scratch builds stay in 'done' state
|
||||
if not build.scratch:
|
||||
@@ -349,8 +365,15 @@ def wait(msg_id, module_build_id, module_build_state):
|
||||
"Note that retrieved module state %r doesn't match message module state %r",
|
||||
build.state, module_build_state,
|
||||
)
|
||||
# This is ok.. it's a race condition we can ignore.
|
||||
pass
|
||||
|
||||
if conf.strict_module_state_transitions:
|
||||
valid_states = (
|
||||
models.BUILD_STATES["init"],
|
||||
models.BUILD_STATES["wait"],
|
||||
)
|
||||
if build.state not in valid_states:
|
||||
log.error("Module wait handler called while module in state %r", build.state)
|
||||
return
|
||||
|
||||
try:
|
||||
build_deps = get_module_build_dependencies(build)
|
||||
|
||||
Reference in New Issue
Block a user