-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(stop): store engine logs of stopped workflow (#563) #563
Conversation
Note that the method
Proper design/planning is needed, though. Should we do it later or as part of this PR? |
76a8c5c
to
f7ddd50
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #563 +/- ##
==========================================
+ Coverage 72.83% 73.23% +0.40%
==========================================
Files 15 15
Lines 1362 1360 -2
==========================================
+ Hits 992 996 +4
+ Misses 370 364 -6
|
f7ddd50
to
e1f8b39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fully support the idea of a refactor, especially to create a single point from which to update the status of a workflow. However, maybe it's better if we create a ticket for it and work on it later, as part of the next minor release, so we can focus on finishing what's left for the patch release and fixing this bug without the risk of changing the code in a lot of places. WDYT?
workflow.status = RunStatus.stopped | ||
Session.add(workflow) | ||
if workflow.can_transition_to(RunStatus.stopped): | ||
_update_workflow_status(workflow, RunStatus.stopped, logs="") | ||
Session.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess calling Session.commit()
here is unnecessary, since it is already being called by _update_workflow_status
(here the reana_db
code), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still needed because even though the status is commited by Workflow.update_workflow_status
, the logs are fetched and saved to the database after that:
reana-workflow-controller/reana_workflow_controller/consumer.py
Lines 143 to 156 in 817b019
def _update_workflow_status(workflow, status, logs): | |
"""Update workflow status in DB.""" | |
if workflow.status != status: | |
Workflow.update_workflow_status(Session, workflow.id_, status, logs, None) | |
if workflow.git_ref: | |
_update_commit_status(workflow, status) | |
if status not in ALIVE_STATUSES: | |
workflow.run_finished_at = datetime.now() | |
workflow.logs = workflow.logs or "" | |
try: | |
workflow_engine_logs = _get_workflow_engine_pod_logs(workflow) | |
workflow.logs += workflow_engine_logs + "\n" |
e1f8b39
to
199c163
Compare
I agree! I have opened a new issue: #565 |
Closes #560
Depends on #559