Skip to content

Commit

Permalink
minor: 重构回滚部分的实现
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang committed Sep 18, 2023
1 parent ae798d0 commit c7d779f
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 123 deletions.
20 changes: 11 additions & 9 deletions runtime/bamboo-pipeline/pipeline/contrib/rollback/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,39 @@
specific language governing permissions and limitations under the License.
"""
from pipeline.contrib.rollback.constants import TOKEN
from pipeline.contrib.rollback.handler import RollbackHandler
from pipeline.contrib.rollback.handler import RollbackDispatcher
from pipeline.contrib.utils import ensure_return_pipeline_contrib_api_result


@ensure_return_pipeline_contrib_api_result
def rollback(root_pipeline_id: str, start_node_id: str, target_node_id: str, mode: str = TOKEN):
def rollback(
root_pipeline_id: str, start_node_id: str, target_node_id: str, skip_rollback_nodes: list = None, mode: str = TOKEN
):
"""
:param root_pipeline_id: pipeline id
:param start_node_id: 开始的 id
:param target_node_id: 开始的 id
:param mode 回滚模式
:return: True or False
"""
RollbackHandler(root_pipeline_id, mode).rollback(start_node_id, target_node_id)
RollbackDispatcher(root_pipeline_id, mode).rollback(start_node_id, target_node_id)


@ensure_return_pipeline_contrib_api_result
def reserve_rollback(root_pipeline_id: str, start_node_id: str, target_node_id: str, mode: str = TOKEN):
RollbackHandler(root_pipeline_id, mode).reserve_rollback(start_node_id, target_node_id)
RollbackDispatcher(root_pipeline_id, mode).reserve_rollback(start_node_id, target_node_id)


@ensure_return_pipeline_contrib_api_result
def retry_rollback_failed_node(root_pipeline_id: str, node_id: str, retry_data: dict = None, mode: str = TOKEN):
RollbackHandler(root_pipeline_id, mode).retry_rollback_failed_node(node_id, retry_data)
def cancel_reserved_rollback(root_pipeline_id: str, start_node_id: str, target_node_id: str, mode: str = TOKEN):
RollbackDispatcher(root_pipeline_id, mode).cancel_reserved_rollback(start_node_id, target_node_id)


@ensure_return_pipeline_contrib_api_result
def cancel_reserve_rollback(root_pipeline_id: str, start_node_id: str, target_node_id: str, mode: str = TOKEN):
RollbackHandler(root_pipeline_id, mode).cancel_reserved_rollback(start_node_id, target_node_id)
def retry_rollback_failed_node(root_pipeline_id: str, node_id: str, retry_data: dict = None, mode: str = TOKEN):
RollbackDispatcher(root_pipeline_id, mode).retry_rollback_failed_node(node_id, retry_data)


@ensure_return_pipeline_contrib_api_result
def get_allowed_rollback_node_id_list(root_pipeline_id: str, start_node_id: str, mode: str = TOKEN):
return RollbackHandler(root_pipeline_id, mode).get_allowed_rollback_node_id_list(start_node_id)
return RollbackDispatcher(root_pipeline_id, mode).get_allowed_rollback_node_id_list(start_node_id)
Loading

0 comments on commit c7d779f

Please sign in to comment.