Skip to content
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

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

mdonadoni
Copy link
Member

Closes #560

Depends on #559

@mdonadoni
Copy link
Member Author

Note that the method _update_workflow_status in consumer.py is now being called in rest/utils.py. I think a refactor is needed, in particular:

  1. The logic on how to update the status/logs/job progress/job cache of workflows should not be in consumer.py, but in a dedicated module/package
  2. There should only be one way (thus, one function) to stop a workflow (and to start/delete/... it), which both updates the database and interacts with k8s as needed. These functions would/should use the ones from (1), and should not be part of rest.

Proper design/planning is needed, though. Should we do it later or as part of this PR?

@mdonadoni mdonadoni force-pushed the engine-logs-stopped-wf branch from 76a8c5c to f7ddd50 Compare January 29, 2024 16:06
mdonadoni added a commit to mdonadoni/reana-workflow-controller that referenced this pull request Jan 29, 2024
mdonadoni pushed a commit to mdonadoni/reana-workflow-controller that referenced this pull request Jan 29, 2024
Copy link

codecov bot commented Jan 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (817b019) 72.83% compared to head (199c163) 73.23%.

Additional details and impacted files

Impacted file tree graph

@@            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     
Files Coverage Δ
reana_workflow_controller/rest/utils.py 81.79% <100.00%> (-0.11%) ⬇️

... and 1 file with indirect coverage changes

mdonadoni added a commit to mdonadoni/reana-workflow-controller that referenced this pull request Jan 29, 2024
mdonadoni pushed a commit to mdonadoni/reana-workflow-controller that referenced this pull request Jan 29, 2024
@mdonadoni mdonadoni force-pushed the engine-logs-stopped-wf branch from f7ddd50 to e1f8b39 Compare January 29, 2024 16:09
Copy link
Member

@giuseppe-steduto giuseppe-steduto left a 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()
Copy link
Member

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?

Copy link
Member Author

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:

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"

@mdonadoni
Copy link
Member Author

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?

I agree! I have opened a new issue: #565

@mdonadoni mdonadoni merged commit 199c163 into reanahub:master Feb 1, 2024
14 checks passed
@mdonadoni mdonadoni deleted the engine-logs-stopped-wf branch February 1, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stopped workflow do not have engine logs
2 participants