-
Notifications
You must be signed in to change notification settings - Fork 75
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: Statefulset pod should change IP when recreating with a changed pool in annotation #3669
Conversation
21368fd
to
039d17f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3669 +/- ##
==========================================
- Coverage 81.21% 81.16% -0.05%
==========================================
Files 50 50
Lines 4391 4391
==========================================
- Hits 3566 3564 -2
- Misses 669 670 +1
- Partials 156 157 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
b244c4b
to
f514448
Compare
need add a new E2E for this bug |
@@ -70,7 +73,7 @@ func (sm *statefulSetManager) ListStatefulSets(ctx context.Context, cached bool, | |||
// IsValidStatefulSetPod only serves for StatefulSet pod, it will check the pod whether need to be cleaned up with the given params podNS, podName. | |||
// Once the pod's controller StatefulSet was deleted, the pod's corresponding IPPool IP and Endpoint need to be cleaned up. | |||
// Or the pod's controller StatefulSet decreased its replicas and the pod's index is out of replicas, it needs to be cleaned up too. | |||
func (sm *statefulSetManager) IsValidStatefulSetPod(ctx context.Context, namespace, podName, podControllerType string) (bool, error) { | |||
func (sm *statefulSetManager) IsValidStatefulSetPod(ctx context.Context, namespace, podName, podControllerType string, endpoint *spiderpoolv2beta1.SpiderEndpoint) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得 这个 api 是 验证 pod 是否是一个有效的 statefulset pod 副本,是否在 副本数 范围内。 而 新加入的代码却使得该 函数 超出了本身的 功能定位,成为一个 非常 杂的 函数 。 它甚至 影响了 GC 等场景的IP回收场景的行为,会产生bug , 对现有代码逻辑影响比较大
新代码我建议是 独立为新一个函数来调用,如 verifyStaterfulSetPodIPValidity() , 来确认当前的 st pod 的 ip 是否是 有效的,是否符合 annotation
27f42c8
to
7032602
Compare
pkg/ipam/allocate.go
Outdated
@@ -98,6 +145,22 @@ func (i *ipam) Allocate(ctx context.Context, addArgs *models.IpamAddArgs) (*mode | |||
return addResp, nil | |||
} | |||
|
|||
func checkEndpointInPool(endpointMap, poolMap map[string]map[string]struct{}) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 api 可以移动到 utils.go 下 , 然后 换个表述 可能会更好理解 函数的作用
checkNicPoolExistence( current, expected map[string]map[string]struct{} ) bool
pkg/ipam/allocate.go
Outdated
endpointMap[ip.NIC][*ip.IPv6Pool] = struct{}{} | ||
} | ||
} | ||
if !checkEndpointInPool(endpointMap, poolMap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 不需要释放,也需要一条 debug 日志,知道 代码做了什么检查
stateful pod 的 ip (什么ip,属于什么ippool)符合当前 期望的 ippool ( ippool 打印出来), 不需要释放 ip
7032602
to
366ae3a
Compare
9b0c489
to
ee48fbc
Compare
38decb6
to
5d150fa
Compare
modify the relevant doc |
A00009 |
5d150fa
to
f596700
Compare
f596700
to
81f84a1
Compare
a5c01a7
to
e677c73
Compare
Signed-off-by: lou-lan <loulan@loulan.me>
e677c73
to
670dab2
Compare
Fix: Statefulset pod should change IP when recreating with a changed pool in annotation Signed-off-by: robot <tao.yang@daocloud.io>
Fix: Statefulset pod should change IP when recreating with a changed pool in annotation Signed-off-by: robot <tao.yang@daocloud.io>
Fix #3543