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

Fix the problem of not initializing extensions in the plugin properly #5236

Conversation

JohnNiang
Copy link
Member

What type of PR is this?

/kind bug
/area core
/milestone 2.12.x

What this PR does / why we need it:

This PR waits extensions deleted when stopping plugins and rearrange destruction order between plugin manager and reconcilers.

See #5226 for more.

Which issue(s) this PR fixes:

Fixes #5226

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

Signed-off-by: John Niang <johnniang@foxmail.com>
@f2c-ci-robot f2c-ci-robot bot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. labels Jan 23, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.12.x milestone Jan 23, 2024
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Jan 23, 2024
Signed-off-by: John Niang <johnniang@foxmail.com>
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (95878b3) 57.06% compared to head (d52c7d5) 57.03%.
Report is 7 commits behind head on main.

Files Patch % Lines
.../halo/app/plugin/PluginBeforeStopSyncListener.java 5.26% 18 Missing ⚠️
...extension/controller/DefaultControllerManager.java 33.33% 6 Missing and 2 partials ⚠️
...ava/run/halo/app/plugin/PluginStartedListener.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5236      +/-   ##
============================================
- Coverage     57.06%   57.03%   -0.03%     
- Complexity     3333     3338       +5     
============================================
  Files           584      584              
  Lines         19190    19221      +31     
  Branches       1444     1445       +1     
============================================
+ Hits          10950    10963      +13     
- Misses         7664     7680      +16     
- Partials        576      578       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2024
@guqing
Copy link
Member

guqing commented Jan 24, 2024

/remove-approve

我发现升级 oauth2 插件等待移除 extensions 的时间很长超过一分钟:

2024-01-24T17:16:27.099+08:00
2024-01-24T17:17:27.427+08:00

java.lang.IllegalStateException: Timeout on blocking read for 60000000000 NANOSECONDS

虽然最终会自愈,但是反复升级试了几次总是能复现,可以配合 #5245 一起测试
相关日志:

log.log

Copy link

f2c-ci-robot bot commented Jan 24, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from johnniang. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2024
@JohnNiang
Copy link
Member Author

@guqing

/remove-approve

我发现升级 oauth2 插件等待移除 extensions 的时间很长:

2024-01-24T17:16:27.099+08:00 2024-01-24T17:17:27.427+08:00

java.lang.IllegalStateException: Timeout on blocking read for 60000000000 NANOSECONDS

虽然最终会自愈,但是反复升级试了几次总是能复现,可以配合 #5245 一起测试 相关日志:

log.log

应该是删除的资源中包含了 finalizers,此时负责删除 finalizers 的 reconciler 已经停止了。目前对 core 中的 reconciler 的启动顺序做了处理,可能是插件中的 reconciler 提前停止导致的。稍后我排查一下。

@guqing
Copy link
Member

guqing commented Jan 24, 2024

@guqing

/remove-approve
我发现升级 oauth2 插件等待移除 extensions 的时间很长:
2024-01-24T17:16:27.099+08:00 2024-01-24T17:17:27.427+08:00
java.lang.IllegalStateException: Timeout on blocking read for 60000000000 NANOSECONDS
虽然最终会自愈,但是反复升级试了几次总是能复现,可以配合 #5245 一起测试 相关日志:
log.log

应该是删除的资源中包含了 finalizers,此时负责删除 finalizers 的 reconciler 已经停止了。目前对 core 中的 reconciler 的启动顺序做了处理,可能是插件中的 reconciler 提前停止导致的。稍后我排查一下。

好的 ❤️‍🔥

@JohnNiang
Copy link
Member Author

目前我更倾向系统停止的时候不执行 pluginManager#stopPlugins 方法, 在系统再次启动的时候,会自动覆盖 extension 数据。这样是否可行呢?@guqing

@guqing
Copy link
Member

guqing commented Jan 25, 2024

目前我更倾向系统停止的时候不执行 pluginManager#stopPlugins 方法, 在系统再次启动的时候,会自动覆盖 extension 数据。这样是否可行呢?@guqing

Halo 停止时,是否可以通过不发出插件停止事件 HaloPluginStoppedEvent 来实现呢

@JohnNiang
Copy link
Member Author

目前我更倾向系统停止的时候不执行 pluginManager#stopPlugins 方法, 在系统再次启动的时候,会自动覆盖 extension 数据。这样是否可行呢?@guqing

Halo 停止时,是否可以通过不发出插件停止事件 HaloPluginStoppedEvent 来实现呢

我们只需要在 destroy PluginManager 的时候不调用 #stopPlugins 方法即可。

@guqing
Copy link
Member

guqing commented Jan 25, 2024

目前我更倾向系统停止的时候不执行 pluginManager#stopPlugins 方法, 在系统再次启动的时候,会自动覆盖 extension 数据。这样是否可行呢?@guqing

Halo 停止时,是否可以通过不发出插件停止事件 HaloPluginStoppedEvent 来实现呢

我们只需要在 destroy PluginManager 的时候不调用 #stopPlugins 方法即可。

那需要测试一下停止 Halo 时插件的 ApplicationContext 能否被正确关闭如果可以的话应该没什么问题

@JohnNiang
Copy link
Member Author

/hold

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 25, 2024
@JohnNiang
Copy link
Member Author

Close in favor of #5251.

/close

@JohnNiang JohnNiang closed this Jan 25, 2024
@JohnNiang JohnNiang deleted the bug/should-wait-for-extensions-deletion branch January 25, 2024 07:35
@ruibaby ruibaby modified the milestones: 2.12.x, 2.12.0 Jan 26, 2024
f2c-ci-robot bot pushed a commit that referenced this pull request Jan 26, 2024
#### What type of PR is this?

/kind improvement
/area core
/area plugin
/milestone 2.12.x

#### What this PR does / why we need it:

This PR mainly simplifies halo plugin manager. Before this,
- we have too many repeat code from super class, which is uncessary
- we maintain plugin application context in ExtensionComponentsFinder, which is uncessary and is hard to manage
- we fire halo plugin event in halo plugin manager, which is complicated and leads to too many repeat code

This PR does:
- refactor halo plugin manager
- wrap base plugin with spring plugin which contains application context
- remove ExtensionComponentsFinder
- bridge halo plugin event and spring plugin event
- wait extensions fully deleted when stopping

Meanwhile, this PR will supersede PR <#5236>.

#### Which issue(s) this PR fixes:

Fixes #5226

#### Special notes for your reviewer:

Test installing, enabing, disabling, upgrading, reloading and deleting plugins.

#### Does this PR introduce a user-facing change?

```release-note
None
```
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 do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/bug Categorizes issue or PR as related to a bug. release-note-none Denotes a PR that doesn't merit a release note.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes not to initialize extensions in the plugin properly
3 participants