Skip to content

Commit

Permalink
fixed handling errors during run start
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Aug 30, 2023
1 parent cf39429 commit fa1157e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
5 changes: 5 additions & 0 deletions server/kraken/server/bg/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions server/kraken/server/exec_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions server/kraken/server/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
6 changes: 4 additions & 2 deletions ui/src/app/flow-page/flow-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@
</div>
</div>

<div *ngIf="selectedNode.run && selectedNode.run.note" style="margin-top: 1em;">
<p-message severity="warn" text="Note: {{ selectedNode.run.note }}"></p-message>
<div *ngIf="selectedNode.run && selectedNode.run.note"
class="mt-3 p-2 w-full shadow-1 border-round-sm"
style="background-color: var(--yellow-200);color: var(--yellow-800);">
<pre style="white-space: pre-wrap;">{{ selectedNode.run.note }}</pre>
</div>

<div *ngIf="!selectedNode.run">
Expand Down

0 comments on commit fa1157e

Please sign in to comment.