Skip to content

Commit

Permalink
Merge pull request #18594 from mvdbeek/include_invocation_in_exception
Browse files Browse the repository at this point in the history
[24.1] Include workflow invocation id in exception logs
  • Loading branch information
mvdbeek authored Aug 2, 2024
2 parents fba5024 + ebf8dcd commit 5ae1363
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
15 changes: 15 additions & 0 deletions lib/galaxy/schema/invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ class FailureReason(str, Enum):
unexpected_failure = "unexpected_failure"


# The reasons below are attached to the invocation and user-actionable.
# Not included are `unexpected_failure` and `expression_evaluation_failed`.
# If expression evaluation fails we're not attaching the templated
# expression to the invocation, as it could contain secrets.
# If the failure reason is not in `FAILURE_REASONS_EXPECTED` we should
# log an exception so admins can debug and/or submit bug reports.
FAILURE_REASONS_EXPECTED = (
FailureReason.dataset_failed,
FailureReason.collection_failed,
FailureReason.job_failed,
FailureReason.output_not_found,
FailureReason.when_not_boolean,
)


class CancelReason(str, Enum):
"""Possible reasons for a cancelled workflow."""

Expand Down
9 changes: 7 additions & 2 deletions lib/galaxy/workflow/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)
from galaxy.schema.invocation import (
CancelReason,
FAILURE_REASONS_EXPECTED,
FailureReason,
InvocationCancellationHistoryDeleted,
InvocationFailureCollectionFailed,
Expand Down Expand Up @@ -251,8 +252,12 @@ def invoke(self) -> Dict[int, Any]:
step_delayed = delayed_steps = True
self.progress.mark_step_outputs_delayed(step, why=de.why)
except Exception as e:
log.exception(
"Failed to schedule %s, problem occurred on %s.",
log_function = log.exception
if isinstance(e, modules.FailWorkflowEvaluation) and e.why.reason in FAILURE_REASONS_EXPECTED:
log_function = log.info
log_function(
"Failed to schedule %s for %s, problem occurred on %s.",
self.workflow_invocation.log_str(),
self.workflow_invocation.workflow.log_str(),
step.log_str(),
)
Expand Down

0 comments on commit 5ae1363

Please sign in to comment.