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

节点&任务状态优化 #7066

Merged
merged 31 commits into from
Dec 20, 2023
Merged

Conversation

ZhuoZhuoCrayon
Copy link
Member

No description provided.

@ZhuoZhuoCrayon ZhuoZhuoCrayon requested review from ywywZhou and hanshuaikang and removed request for ywywZhou September 13, 2023 07:00
@ZhuoZhuoCrayon ZhuoZhuoCrayon linked an issue Sep 26, 2023 that may be closed by this pull request
@ZhuoZhuoCrayon ZhuoZhuoCrayon force-pushed the feature/issue_6653 branch 3 times, most recently from 350768c to 787475e Compare October 11, 2023 01:11
@ZhuoZhuoCrayon ZhuoZhuoCrayon changed the base branch from release_horse to release_humming_bird October 11, 2023 02:12
@ZhuoZhuoCrayon ZhuoZhuoCrayon self-assigned this Oct 11, 2023
@ZhuoZhuoCrayon ZhuoZhuoCrayon changed the title 执行中任务状态展示及过滤优化 节点&任务状态优化 Oct 11, 2023
project_id=taskflow_instance.project_id,
)
get_task_status_result: typing.Dict[str, typing.Any] = dispatcher.get_task_status(with_ex_data=False)
if get_task_status_result.get("result"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于状态是否为 pending_process的逻辑可以直接在这里处理,在这一步就可以筛选出来 pending_process_taskflow_ids

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于状态是否为 pending_process的逻辑可以直接在这里处理,在这一步就可以筛选出来 pending_process_taskflow_ids

不行,get_task_status 相对于 DB 查询来说,是一个耗时操作,需要先 DB 过滤出 RUNNING 的流程,再根据 RUNNING 判断最终状态是「等待处理」的流程,这样走 get_task_status 的任务数量在一个项目下就非常可控。

.values("root_id")
.distinct()
return self.queryset.exclude(
pipeline_instance_id__in=self._fetch_pipeline_instance_ids(statuses=[states.FAILED, states.SUSPENDED])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看我的注释,是 未完成的任务 -(暂停 + 失败的任务),这里改的好像有问题

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看我的注释,是 未完成的任务 -(暂停 + 失败的任务),这里改的好像有问题

已确认,没有问题

# selected_related 只能在 objects 最前面加,此处先查处 ID 列表
taskflow_instance_ids: typing.List[int] = list(
self.queryset.exclude(
pipeline_instance_id__in=self._fetch_pipeline_instance_ids(statuses=[states.FAILED])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

等待处理应该只存在running状态下的任务,这里可以只拿处于running状态的taskflow_instance

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

等待处理应该只存在running状态下的任务,这里可以只拿处于running状态的taskflow_instance

逻辑就是这样,exclude


# Raise StopIteration if not found
task_id: typing.Optional[int] = next(
(node_output["value"] for node_output in node_outputs if node_output["key"] == "task_id")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是取第一个task吗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是取第一个task吗

不是,因为输出是 k-v,这里是遍历取第一个名为 task_id 的键

return (
notify_type
if isinstance(notify_type, dict)
else {"success": notify_type, "fail": notify_type, "pending_processing": []}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{"success": notify_type, "fail": notify_type, "pending_processing": notify_type}
是不是应该跟上面保持一致

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{"success": notify_type, "fail": notify_type, "pending_processing": notify_type} 是不是应该跟上面保持一致

已修改

@@ -189,6 +191,13 @@ def bamboo_engine_eri_post_set_state_handler(sender, node_id, to_state, version,

_finish_taskflow_and_send_signal(root_id, taskflow_finished, True)

elif to_state == bamboo_engine_states.SUSPENDED and node_id == root_id:
# TODO 发送通知,向上找到根流程,发送通知
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块是否需要确认完再合入

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块是否需要确认完再合入

已去除,按之前讨论的:独立子流程继承父流程通知配置

@@ -83,6 +85,15 @@ def execute(self, data, parent_data):
return False

data.outputs.sn = result["data"]["sn"]

task_id: int = parent_data.get_one_of_inputs("task_id")
send_taskflow_message.delay(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前发送通知的进程配置较低,需要看看这块加上之后是否需要调整进程资源

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前发送通知的进程配置较低,需要看看这块加上之后是否需要调整进程资源

后续关注


if skip_if_not_status:
# 满足某个具体状态才发通知
dispatcher = TaskCommandDispatcher(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

个人认为这个地方不应该有查询任务状态的操作,这个函数的功能抽象未发送任务消息,至于发送什么消息和配置,理论上应该在外部确认好传入

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

个人认为这个地方不应该有查询任务状态的操作,这个函数的功能抽象未发送任务消息,至于发送什么消息和配置,理论上应该在外部确认好传入

讨论结论:不做「等待处理」的整体状态判断,节点走到便发通知。
背景:并行网关场景下一分支有失败节点,另一分支有审批/人工确认场景下,任务状态是失败,如果这种场景发通知是否合理。

else:
return {"id": taskflow_instance.id, "state": None}

task_status_infos: typing.List[typing.Dict[str, typing.Any]] = concurrent.batch_call(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块的逻辑可能对 db 有比较大的请求,需要考虑下这块风险

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块的逻辑可能对 db 有比较大的请求,需要考虑下这块风险

先 DB 过滤出 RUNNING 的流程,再根据 RUNNING 判断最终状态是「等待处理」的流程,这样走 get_task_status 的任务数量在一个项目下就非常可控。

ZhuoZhuoCrayon and others added 3 commits November 7, 2023 12:07
…ture/issue_6653_bird

# Conflicts:
#	frontend/desktop/src/assets/fonts/bksops-icon.eot
#	frontend/desktop/src/assets/fonts/bksops-icon.svg
#	frontend/desktop/src/assets/fonts/bksops-icon.ttf
#	frontend/desktop/src/assets/fonts/bksops-icon.woff
#	frontend/desktop/src/config/i18n/cn.js
#	frontend/desktop/src/config/i18n/en.js
#	frontend/desktop/src/pages/task/TaskExecute/TaskOperation.vue
#	frontend/desktop/src/scss/iconfont.scss
#	gcloud/core/apis/drf/viewsets/taskflow.py
ZhuoZhuoCrayon and others added 20 commits November 22, 2023 09:39
* optimization: 任务状态联调

* optimization: 任务状态联调
* fix: 节点详情是否允许操作逻辑优化
# Reviewed, transaction id: 591

* fix: 失败后跳过节点展示报错信息
# Reviewed, transaction id: 592

* fix: 任务列表【等待处理】传参优化
# Reviewed, transaction id: 594

* fix: 失败后跳过展示异常修复
# Reviewed, transaction id: 596

* fix: 节点详情状态的icon对齐节点右上角icon
# Reviewed, transaction id: 602
# Reviewed, transaction id: 621
* optimization: 更换icon&&任务详情中画布连线取消hover效果
# Reviewed, transaction id: 624

* optimization: 设置了自动重试的节点,点击 "暂停执行" 后,不给节点后面的线条加样式
# Reviewed, transaction id: 628
@hanshuaikang hanshuaikang merged commit 8cd814e into release_humming_bird Dec 20, 2023
5 of 6 checks passed
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.

节点&任务状态优化
4 participants