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

[FEATURE] 后台插件支持配置超时时间 #1696

Closed
ZhuoZhuoCrayon opened this issue Jul 23, 2023 · 3 comments
Closed

[FEATURE] 后台插件支持配置超时时间 #1696

ZhuoZhuoCrayon opened this issue Jul 23, 2023 · 3 comments
Labels
done 已上线到正式环境并验收通过

Comments

@ZhuoZhuoCrayon
Copy link
Member

你想要什么功能
后台插件支持超时参数

为什么需要
部分逻辑,如 Agent 状态查询,Job 操作实际不需要 6 分钟这么久,希望在某些场景,可以通过调小超时参数,提升用户等待体验,提前暴露问题

建议如何实现

范围:Job 相关插件、GetAgentStatusService

apps/backend/components/collections/base.py BaseService -> PollingTimeoutMixin(with polling_timeout in inputs_format)

apps/backend/agent/manager.py 参考 wait 方法,支持传入 polling_timeout

@ZhuoZhuoCrayon ZhuoZhuoCrayon added the backlog 需求初始状态,等待产品进行评估 label Jul 23, 2023
@ZhuoZhuoCrayon ZhuoZhuoCrayon changed the title [FEATURE] 后台插件支持超时参数 [FEATURE] 后台插件支持配置超时时间 Jul 23, 2023
@neko12583
Copy link
Collaborator

方案

大概实现逻辑

创建 PollingTimeoutMixin 类,BaseService 类继承 PollingTimeoutMixin

PollingTimeoutMixin 中创建 polling_timeout 方法,使用 @property 进行装饰,提供给子类使用 self.polling_timeout 调用

支持可配置超时时间的插件在 _schedule 方法中,将取自 constants.pyPOLLING_TIMEOUT 改为 self.polling_timeout

详细实现逻辑

polling_timeout

PollingTimeoutMixinpolling_timeout 方法从 GlobalSettings 中调用 get_config 获取 POLLING_TIMEOUT

默认为 constants.POLLING_TIMEOUT = 60 * 6

GlobalSettingsPOLLING_TIMEOUT 为字典,可对指定插件对超时时间进行配置:

# {self.component_cls().name: POLLING_TIMEOUT}
POLLING_TIMEOUT = {"get_agent_status": 120}

自测点

  • 不进行配置能够正常安装agent
  • 设置 POLLING_TIMEOUT = {"get_agent_status": 120} 能够正常安装agent
  • 设置 POLLING_TIMEOUT = {"get_agent_status": 1} 安装agent会超时失败

@neko12583
Copy link
Collaborator

方案更改

上述方案中,由于作业组件的超时时间在抽象类中实现,不能获取绑定组件的 code,将 GlobalSettings 中添加配置 BACKEND_SERVICE_POLLING_TIMEOUT

BACKEND_SERVICE_POLLING_TIMEOUT 为字典,键为服务类名,值为超时时间

@neko12583
Copy link
Collaborator

功能自测

不配置超时时间可正常执行任务

企业微信截图_20231019193134

配置超时时间为1秒超时失败

企业微信截图_20231019193439
企业微信截图_20231019195504

配置超时时间为20秒可正常执行

企业微信截图_20231023180542

@wyyalt wyyalt added for test 可以在测试环境进行验收 tested 已经在测试环境验收通过 done 已上线到正式环境并验收通过 and removed backlog 需求初始状态,等待产品进行评估 for test 可以在测试环境进行验收 tested 已经在测试环境验收通过 labels Oct 30, 2023
@wyyalt wyyalt closed this as completed in 3d8433d Nov 2, 2023
@github-project-automation github-project-automation bot moved this to In progress in v2.4.3 Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done 已上线到正式环境并验收通过
Projects
Status: In progress
Development

No branches or pull requests

3 participants