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

[OPTIMIZATION] 分页时展示 Agent 实时状态 #752

Closed
ZhuoZhuoCrayon opened this issue May 13, 2022 · 3 comments
Closed

[OPTIMIZATION] 分页时展示 Agent 实时状态 #752

ZhuoZhuoCrayon opened this issue May 13, 2022 · 3 comments
Assignees
Labels
done 已上线到正式环境并验收通过 kind/optimization 优化 module/saas SaaS priority/middle 中等优先级(Medium priority) version/V2.2.X V2.2.X

Comments

@ZhuoZhuoCrayon
Copy link
Member

ZhuoZhuoCrayon commented May 13, 2022

background

why

Function

what functionality do you want

Function realization

Suggested solution

    def fill_agent_state_info_to_hosts(self, host_infos: typing.List[types.HostInfo]):
        """实时查询 Agent 状态信息,并填充到主机信息列表"""
        if len(host_infos) > 2000:
            return host_infos

        host_ids = [host_info["bk_host_id"] for host_info in host_infos]
        try:
             host_id__agent_state_info = update_or_create_host_agent_status(node_man_models.Host.objects.filter(bk_host_id__in=host_ids))
        except
            return host_infos


        for host_info in host_infos:
            try:
                host_info["status"] = host_id__agent_state_info["bk_host_id"]["status_display"]
                host_info["version"] = ...
            except KeyError:
                pass

Implementation

Function self-test

Code change coverage function points need self-test and screenshots

Function Point 1

Describe code changes involving function points and self-test screenshots

Function point 2

Describe code changes involving function points and self-test screenshots

@ZhuoZhuoCrayon ZhuoZhuoCrayon added kind/optimization 优化 module/saas SaaS version/V2.2.X V2.2.X priority/middle 中等优先级(Medium priority) labels May 13, 2022
@ZhuoZhuoCrayon ZhuoZhuoCrayon self-assigned this May 13, 2022
@ZhuoZhuoCrayon
Copy link
Member Author

筛选逻辑带有 Agent 状态 如何处理?

@ZhuoZhuoCrayon ZhuoZhuoCrayon changed the title [OPTIMIZATION] 通过 IP 过滤返回 Agent 实时状态 [OPTIMIZATION] 分页时展示 Agent 实时状态 Dec 11, 2022
@CohleRustW
Copy link
Collaborator

CohleRustW commented Jul 19, 2023

实现方案

实现方向

  1. 全量拉取时不去更新主机状态,只在分页场景下刷新主机状态
  2. 当筛选条件包含 Agent 状态/版本 时,不刷新主机状态

代码实现

  1. multiple_cond_sql 增加参数判断是否进行状态表的级联查询
  2. 补充update_or_create_host_agent_status 返回主机实时状态和版本信息映射表
  3. 回填查询到不带主机状态信息的结果中的主机状态和版本信息

@CohleRustW
Copy link
Collaborator

自测结果

填充 Agent 数据前,本地测试代码中增加破坏数据

ProcessStatus.objects.filter(name=ProcessStatus.GSE_AGENT_PROCESS_NAME, bk_host_id__in=bk_host_ids).update(status="TERMINATED")
  1. fill_agent_state_info_to_hosts 异常时
image image
  1. 当长度超过 QUERY_AGENT_STATUS_HOST_LENS
image image
  1. 正常获取 Agent 状态的情况下
image

@CohleRustW CohleRustW added the grayed 已经在灰度环境/预发布环境验收通过 label Jul 28, 2023
@ZhuoZhuoCrayon ZhuoZhuoCrayon added for test 可以在测试环境进行验收 and removed grayed 已经在灰度环境/预发布环境验收通过 labels Jul 31, 2023
@wyyalt wyyalt added tested 已经在测试环境验收通过 and removed for test 可以在测试环境进行验收 labels Aug 10, 2023
@wyyalt wyyalt added done 已上线到正式环境并验收通过 and removed tested 已经在测试环境验收通过 labels Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done 已上线到正式环境并验收通过 kind/optimization 优化 module/saas SaaS priority/middle 中等优先级(Medium priority) version/V2.2.X V2.2.X
Projects
None yet
Development

No branches or pull requests

3 participants