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

建议重构插件依赖相关的插件启动逻辑 #5872

Open
guqing opened this issue May 8, 2024 · 1 comment · May be fixed by #5900
Open

建议重构插件依赖相关的插件启动逻辑 #5872

guqing opened this issue May 8, 2024 · 1 comment · May be fixed by #5900
Assignees
Labels
area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement.
Milestone

Comments

@guqing
Copy link
Member

guqing commented May 8, 2024

Your current Halo version

2.15.1

Describe this feature

目前插件依赖中关于被依赖插件的停止或启动存在一些问题:

  1. 以应用市场插件为例,应用市场插件被 A 和 B 插件依赖,且都处于启动状态
  2. 停止应用市场插件后会自动停止 A 和 B,然后点击启动 A 会自动启动 B 插件和应用市场插件
  3. 在 Reconciler 中会去监听内存中插件的实际状态并修改 spec.enabled 这违反了 spec 的初衷,spec 是用户期望如果内存中状态不符合应该协调到期望状态

重构点:

  1. 插件的停止和启动前应该加入依赖检测,如果有插件依赖了当前被停止的插件则不允许停止当前插件,如果插件启动时所依赖的插件没有启动应该拒绝启动并给用户提示
  2. 不应该监听内存中插件状态并去修改 spec 来适应内存中的状态,而是要以用户期望状态为准

以升级步骤为例,应该的逻辑是:

  1. 检测依赖插件,比如已经启动的 A,B
  2. 更新 A 和 B 的 annotations 中加入 reload 标记
  3. 检测依赖插件,有就抛出异常 requeue(可能因为抛出异常 requeue 后进入第4步),没有则 reload 应用市场,stop ,unload,load 等步骤
  4. A 和 B 中途可能会进入执行(由于 3 步骤让出了执行权),检测到 reload 标记,执行 reload 操作,但是需要检测依赖插件是否正常,如果没有启动则抛出异常等待。
  5. 应用市场启动完成了,reconciler 轮到 A 执行,检测到 reload 标记执行 reload 等逻辑重复到第3步

如此不在需要停止插件时检测依赖并记录到当前插件然后又再启动后恢复依赖插件的状态,且不需要去以内存中实际状态为主来修改插件 spec.enabled,spec.enabled 是用户期望,无论如何要以用户期望为准,避免出现升级应用市场插件时其他插件被停止而没有自动启动的问题

Additional information

/kind improvement
/area core
/milestone 2.16.x
/assign @JohnNiang

@f2c-ci-robot f2c-ci-robot bot added the kind/improvement Categorizes issue or PR as related to a improvement. label May 8, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.16.x milestone May 8, 2024
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label May 8, 2024
@ruibaby
Copy link
Member

ruibaby commented May 8, 2024

这就叫专业.webp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants