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

Add finalizer to egressgateway #1019

Merged
merged 1 commit into from
Dec 5, 2023
Merged

Conversation

bzsuni
Copy link
Collaborator

@bzsuni bzsuni commented Nov 27, 2023

Fixes

Fix #866
Fix #990

release nodes

To add a finalizer to the `egressgateway` that allows it to be deleted when referenced by `policies`, remaining in the "deleting" state until all referencing `policies` are deleted

description

When creating an egressgateway, add a finalizer to it using a webhook.
When deleting the egressgateway, if it is not referenced by any policies and the finalizer is present, remove the finalizer from the egressgateway and perform an update.

@bzsuni bzsuni added the enhancement New feature or request label Nov 27, 2023
@bzsuni bzsuni requested a review from weizhoublue as a code owner November 27, 2023 10:25
@bzsuni bzsuni added the pr/not-ready not ready for merging label Nov 27, 2023
Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Merging #1019 (9e6aa5e) into main (de9646a) will increase coverage by 0.21%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1019      +/-   ##
==========================================
+ Coverage   43.15%   43.36%   +0.21%     
==========================================
  Files          20       21       +1     
  Lines        3154     3166      +12     
==========================================
+ Hits         1361     1373      +12     
  Misses       1592     1592              
  Partials      201      201              
Flag Coverage Δ
unittests 43.36% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
pkg/controller/webhook/mutating.go 77.66% <ø> (ø)
pkg/utils/slice/slice.go 100.00% <100.00%> (ø)

@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch 5 times, most recently from 71d1068 to d2a3cd0 Compare November 28, 2023 06:40
@bzsuni bzsuni added release/none should not recoded in new release and removed pr/not-ready not ready for merging labels Nov 28, 2023
@bzsuni bzsuni requested a review from lou-lan November 28, 2023 06:58
@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch from d2a3cd0 to 66488af Compare November 28, 2023 07:28
lou-lan
lou-lan previously approved these changes Nov 28, 2023
lou-lan
lou-lan previously approved these changes Nov 28, 2023
@bzsuni
Copy link
Collaborator Author

bzsuni commented Nov 28, 2023

Fix #866

删除 egressgateway 思路:

  1. 创建 egressgateway 时,通过 webhookegressgateway 添加 finalizer
  2. 删除 policy 时,如果其引用的 gatewaydeleting 状态,并且其是最后一个引用这个 gatewaypolicy,则将 egressgateway 中的 finalizer 移除
  3. 删除 egressgateway 时,如果没有被 policy 引用,并且 finalizer 存在时,移除 egressgatewayfinalizer 并 update

步骤 2 没有必要,policy 删除事件 一定 会触发 gateway 更新,在 gateway 中,做移除 finaliizer 的操作即可
from @weizhoublue

lou-lan
lou-lan previously approved these changes Nov 28, 2023
@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch 2 times, most recently from 7e18069 to 4fc372e Compare November 28, 2023 13:37
@weizhoublue weizhoublue added release/feature-new feature pr recoded in new release and removed enhancement New feature or request release/none should not recoded in new release labels Nov 29, 2023
@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch from 4fc372e to b69b107 Compare November 29, 2023 06:28
@weizhoublue
Copy link
Collaborator

weizhoublue commented Nov 29, 2023

@weizhoublue weizhoublue temporarily deployed to pull request November 29, 2023 06:29 Inactive
@weizhoublue weizhoublue temporarily deployed to commit November 29, 2023 06:29 Inactive
lou-lan
lou-lan previously approved these changes Nov 29, 2023
@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch from b69b107 to 8a986c4 Compare November 29, 2023 07:26
@weizhoublue weizhoublue temporarily deployed to commit November 29, 2023 07:27 Inactive
@weizhoublue weizhoublue temporarily deployed to pull request November 29, 2023 07:27 Inactive
@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch from 8a986c4 to dc7f0a8 Compare November 29, 2023 07:29
@weizhoublue weizhoublue temporarily deployed to commit November 29, 2023 07:30 Inactive
@weizhoublue weizhoublue temporarily deployed to pull request November 29, 2023 07:31 Inactive
@weizhoublue weizhoublue added release/feature-changed feature pr recoded in new release and removed release/feature-new feature pr recoded in new release labels Nov 29, 2023
@@ -274,3 +274,8 @@ helm repo update
$ curl 10.6.1.92:8080
Remote IP: 172.22.0.110
```

## 卸载 EgressGateway
为了保证业务不断流,`egressgateway` 中加入了 finalizer 机制,删除 `egressgateway` 时,如果存在 policy 引用此 `egressgateway`,`egressgateway` 会一直处于 deleting 状态,所以,如果要删除 `egressgateway`,建议使用如下步骤:
Copy link
Collaborator

Choose a reason for hiding this comment

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

egressgateway 会一直处于 deleting 状态 .... 直到 所有的 policy 被删除,finalizer 就会被自动删除

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

好的,一会我改一下

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

egressgateway 会一直处于 deleting 状态 .... 直到 所有的 policy 被删除,finalizer 就会被自动删除

已修改

@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch from dc7f0a8 to 50aa628 Compare November 29, 2023 10:28
@weizhoublue weizhoublue temporarily deployed to commit November 29, 2023 10:29 Inactive
@weizhoublue weizhoublue temporarily deployed to pull request November 29, 2023 10:29 Inactive
@bzsuni bzsuni force-pushed the bz/finalizer/egressgateway branch from 50aa628 to 9e6aa5e Compare December 4, 2023 01:47
@weizhoublue weizhoublue temporarily deployed to commit December 4, 2023 01:48 Inactive
@weizhoublue weizhoublue temporarily deployed to pull request December 4, 2023 01:48 Inactive
@weizhoublue weizhoublue merged commit 3531f23 into main Dec 5, 2023
36 checks passed
@weizhoublue weizhoublue deleted the bz/finalizer/egressgateway branch December 5, 2023 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/feature-changed feature pr recoded in new release
Projects
None yet
3 participants