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

minor: 去除any模式下当前正在运行节点的限制 #199

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/bamboo-pipeline/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

default_app_config = "pipeline.apps.PipelineConfig"

__version__ = "3.29.0rc3"
__version__ = "3.29.0rc4"
22 changes: 5 additions & 17 deletions runtime/bamboo-pipeline/pipeline/contrib/rollback/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def validate_token(root_pipeline_id, start_node_id, target_node_id):
)

@staticmethod
def validate_node_state_by_token_mode(root_pipeline_id, start_node_id):
def validate_node_state(root_pipeline_id, start_node_id):
"""
使用token模式下的回滚,相同token的节点不允许有正在运行的节点
"""
Expand Down Expand Up @@ -122,18 +122,6 @@ def validate_node_state_by_token_mode(root_pipeline_id, start_node_id):
)
)

@staticmethod
def validate_node_state_by_any_mode(root_pipeline_id):
"""
使用any模式下的回滚, 不允许有正在运行的节点
"""
if (
State.objects.filter(root_id=root_pipeline_id, name=states.RUNNING)
.exclude(node_id=root_pipeline_id)
.exists()
):
raise RollBackException("rollback failed: there is currently the some node is running")

@staticmethod
def validate_start_node_id(root_pipeline_id, start_node_id):
"""
Expand Down Expand Up @@ -262,12 +250,12 @@ def retry_rollback_failed_node(self, node_id, retry_data):
raise RollBackException("rollback failed: when mode is any, not support retry")

def rollback(self, start_node_id, target_node_id, skip_rollback_nodes=None):
RollbackValidator.validate_node_state_by_any_mode(self.root_pipeline_id)
# 回滚的开始节点运行失败的情况
RollbackValidator.validate_start_node_id(self.root_pipeline_id, start_node_id)
RollbackValidator.validate_node(start_node_id, allow_failed=True)
RollbackValidator.validate_node(target_node_id)
RollbackValidator.validate_token(self.root_pipeline_id, start_node_id, target_node_id)
# 相同token回滚时,不允许同一token路径上有正在运行的节点
RollbackValidator.validate_node_state(self.root_pipeline_id, start_node_id)

node_map = self._get_allowed_rollback_node_map()
rollback_graph = RollbackGraphHandler(node_map=node_map, start_id=start_node_id, target_id=target_node_id)
Expand Down Expand Up @@ -354,11 +342,11 @@ def rollback(self, start_node_id, target_node_id, skip_rollback_nodes=None):
if skip_rollback_nodes is None:
skip_rollback_nodes = []

# 相同token回滚时,不允许有正在运行的节点
RollbackValidator.validate_node_state_by_token_mode(self.root_pipeline_id, start_node_id)
# 回滚的开始节点运行失败的情况
RollbackValidator.validate_node(start_node_id, allow_failed=True)
RollbackValidator.validate_node(target_node_id)
# 相同token回滚时,不允许同一token路径上有正在运行的节点
RollbackValidator.validate_node_state(self.root_pipeline_id, start_node_id)
RollbackValidator.validate_token(self.root_pipeline_id, start_node_id, target_node_id)

# 如果开始节点是失败的情况,则跳过该节点的回滚操作
Expand Down
4 changes: 2 additions & 2 deletions runtime/bamboo-pipeline/pipeline/contrib/rollback/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def execute_rollback(self):
node_snapshots = RollbackNodeSnapshot.objects.filter(node_id=self.node_id, rolled_back=False).order_by("-id")
for node_snapshot in node_snapshots:
service = self.runtime.get_service(code=node_snapshot.code, version=node_snapshot.version)
data = ExecutionData(inputs=json.loads(node_snapshot.inputs), outputs=json.loads(node_snapshot.outputs))
parent_data = ExecutionData(inputs=json.loads(node_snapshot.context_values), outputs={})
data = ExecutionData(inputs=node_snapshot.inputs, outputs=node_snapshot.outputs)
parent_data = ExecutionData(inputs=node_snapshot.context_values, outputs={})
result = service.service.rollback(data, parent_data, self.retry_data)
node_snapshot.rolled_back = True
node_snapshot.save()
Expand Down
2 changes: 1 addition & 1 deletion runtime/bamboo-pipeline/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bamboo-pipeline"
version = "3.29.0rc3"
version = "3.29.0rc4"
description = "runtime for bamboo-engine base on Django and Celery"
authors = ["homholueng <[email protected]>"]
license = "MIT"
Expand Down
Loading