diff --git a/server/kraken/server/bg/jobs.py b/server/kraken/server/bg/jobs.py index ea171fc0..d019dcd0 100644 --- a/server/kraken/server/bg/jobs.py +++ b/server/kraken/server/bg/jobs.py @@ -993,8 +993,13 @@ def refresh_schema_repo(stage_id, complete_starting_run_id=None): ctx = prepare_context(stage, stage.get_default_args()) schema_code, schema = check_and_correct_stage_schema(stage.branch, stage.name, schema_code, ctx) except Exception as e: + if run is not None: + now = utils.utcnow() + exec_utils.complete_run(run, now, "Starting run failed: %s" % str(e)) + stage.repo_error = str(e) stage.repo_state = consts.REPO_STATE_ERROR + db.session.commit() log.exception('problem with schema, stage: %d, run: %s', stage_id, complete_starting_run_id) diff --git a/server/kraken/server/exec_utils.py b/server/kraken/server/exec_utils.py index c34eff53..8eee0018 100644 --- a/server/kraken/server/exec_utils.py +++ b/server/kraken/server/exec_utils.py @@ -27,10 +27,17 @@ log = logging.getLogger(__name__) -def complete_run(run, now): +def complete_run(run, now, note=None): from .bg import jobs as bg_jobs # pylint: disable=import-outside-toplevel run.state = consts.RUN_STATE_COMPLETED + if run.started is None: + run.started = now run.finished = now + if note: + if run.note: + run.note += '\n' + note + else: + run.note = note db.session.commit() log.info('completed run %s, now: %s', run, run.finished) @@ -427,9 +434,7 @@ def trigger_jobs(run, replay=False): except Exception as ex: log.exception('Problem with starting jobs') now = utils.utcnow() - run.started = now - run.note = "Triggering run's jobs failed: %s" % str(ex) - complete_run(run, now) + complete_run(run, now, "Triggering run's jobs failed: %s" % str(ex)) return run.started = now diff --git a/server/kraken/server/management.py b/server/kraken/server/management.py index e8e6a562..4e332965 100644 --- a/server/kraken/server/management.py +++ b/server/kraken/server/management.py @@ -549,7 +549,12 @@ def update_stage(stage_id, body, token_info=None): if 'enabled' in body: stage.enabled = body['enabled'] - if 'schema_code' in body: + if 'schema_from_repo_enabled' in body: + schema_from_repo_enabled = body['schema_from_repo_enabled'] + else: + schema_from_repo_enabled = stage.schema_from_repo_enabled + + if 'schema_code' in body and not schema_from_repo_enabled: prev_triggers = stage.schema['triggers'] ctx = prepare_context(stage, stage.get_default_args()) try: @@ -565,11 +570,6 @@ def update_stage(stage_id, body, token_info=None): flag_modified(stage, 'triggers') log.info('new schema: %s', stage.schema) - if 'schema_from_repo_enabled' in body: - schema_from_repo_enabled = body['schema_from_repo_enabled'] - else: - schema_from_repo_enabled = stage.schema_from_repo_enabled - stage.schema_from_repo_enabled = schema_from_repo_enabled db.session.commit() @@ -616,6 +616,10 @@ def update_stage(stage_id, body, token_info=None): from .bg import jobs as bg_jobs # pylint: disable=import-outside-toplevel kkrq.enq_neck(bg_jobs.refresh_schema_repo, stage.id, 0, ignore_args=[1]) + elif stage.repo_state == consts.REPO_STATE_ERROR: + stage.repo_state = consts.REPO_STATE_OK + stage.repo_error = '' + db.session.commit() result = stage.get_json() diff --git a/ui/src/app/flow-page/flow-page.component.html b/ui/src/app/flow-page/flow-page.component.html index 66ad9521..937b2e38 100644 --- a/ui/src/app/flow-page/flow-page.component.html +++ b/ui/src/app/flow-page/flow-page.component.html @@ -99,8 +99,10 @@ -
- +
+
{{ selectedNode.run.note }}