Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflow_run_manager: workflow stop race condition
* Happening when user stops a workflow before its first job is created. RWC stops only the existing jobs. However, because there is a grace period for stopping pods, RJC sidecar still runs, submitting a new job, and reporting its status, causing the workflow to “revive”. To mitigate this, we decrease the grace period to 0 and we don't allow stopped workflows to change status (closes reanahub/reana-client#395).
- Loading branch information
Diego Rodriguez
committed
Apr 9, 2020
1 parent
b08d617
commit 8495199
Showing
4 changed files
with
65 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of REANA. | ||
# Copyright (C) 2020 CERN. | ||
# | ||
# REANA is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
from reana_db.models import WorkflowStatus | ||
|
||
|
||
def can_transition(workflow, to_status): | ||
"""Can a workflow transition?.""" | ||
transitions = [ | ||
# Creation | ||
(WorkflowStatus.created, WorkflowStatus.deleted), | ||
(WorkflowStatus.created, WorkflowStatus.running), | ||
# Running | ||
(WorkflowStatus.running, WorkflowStatus.failed), | ||
(WorkflowStatus.running, WorkflowStatus.finished), | ||
(WorkflowStatus.running, WorkflowStatus.stopped), | ||
(WorkflowStatus.running, WorkflowStatus.running), | ||
# Stopped | ||
(WorkflowStatus.stopped, WorkflowStatus.deleted), | ||
# Failed | ||
(WorkflowStatus.failed, WorkflowStatus.deleted), | ||
(WorkflowStatus.failed, WorkflowStatus.running), | ||
# Finished | ||
(WorkflowStatus.finished, WorkflowStatus.deleted), | ||
(WorkflowStatus.finished, WorkflowStatus.running), | ||
] | ||
current_transition = (workflow.status, to_status) | ||
return current_transition in transitions |