-
Notifications
You must be signed in to change notification settings - Fork 57
feat: 节点数过多导致 kubelet endpointslice数量不对的情况 --story=130207089 #1194
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
Open
shamcleren
wants to merge
10
commits into
TencentBlueKing:master
Choose a base branch
from
shamcleren:feat/update_operator_discover_kubelet_endpointslice/#1010158081130207089
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: 节点数过多导致 kubelet endpointslice数量不对的情况 --story=130207089 #1194
shamcleren
wants to merge
10
commits into
TencentBlueKing:master
from
shamcleren:feat/update_operator_discover_kubelet_endpointslice/#1010158081130207089
+1,355
−39
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 将 syncNodeEndpoints 中的 EndpointSlice 逻辑提取到 syncEndpointSlices 函数 - 将获取 Service UID 的逻辑合并到 syncEndpointSlices 函数中 - 简化 syncNodeEndpoints 函数,提高代码可读性和可维护性 - 函数职责更清晰,便于测试和维护
jacky15
reviewed
Jan 21, 2026
主要改进:
1. 配置优化:
- 将 maxEndpointsPerSlice 改为可配置项(默认 100,最大 1000)
- 边界检查统一在 setupKubelet 函数中处理,避免重复检查
2. 代码优化:
- 使用 sync.Once + 检查 Endpoints 是否存在,确保只在第一次启动时删除 Endpoints
- 将删除操作移到开头,避免重复采集
- 提前检查 Service 存在性,避免在 Service 不存在时执行删除操作
- 使用 map[string]struct{} 替代 map[string]bool,提升性能和语义清晰度
- 对节点列表按名称排序,确保 EndpointSlice 内容稳定
3. 性能优化:
- CreateOrUpdateEndpointSlice 添加 DeepEqual 检查,避免不必要的更新
- 有序的 address 列表配合 DeepEqual 检查,提升更新效率
4. 代码重构:
- 将 EndpointSlice 同步逻辑封装为独立的 syncEndpointSlices 函数
- 优化代码结构和注释,提高可读性和可维护性
- 合并 SlicesToCreate 和 SlicesToUpdate 为 SlicesToSync,统一使用 CreateOrUpdateEndpointSlice - 添加 rebalance 逻辑,当容量使用率低于阈值时自动合并 slices - 优化填充策略,优先填充已有的 slice,最大化利用空间 - 添加辅助函数 convertAddressesToEndpoints 减少代码重复 - 修复 slice 更新逻辑,确保内容变化时能正确更新 - 优化代码结构,提高可维护性 相关需求: #1010158081130207089
…ointslice/#1010158081130207089
- 修正 syncEndpointSlices 函数注释中的默认值:从 1000 改为 100 - 统一术语:将'更新、新建'统一为'同步',与代码逻辑一致 - 补充 commonEndpointPorts 注释,说明它是只读常量 - 更新执行阶段注释,反映统一使用 CreateOrUpdateEndpointSlice 的逻辑 相关需求: #1010158081130207089
- 为 EndpointSlice 相关代码添加 33 条详细日志 - 使用统一前缀 [kubelet-endpointslice] 方便日志过滤 - 覆盖关键流程:入口判断、资源列举、分析、执行、删除等 - 修复单测:使用 mock 替代真实 ObjectsController - 所有单测通过验证 日志级别分布: - Info: 10 条(关键流程和结果) - Debug: 18 条(详细调试信息) - Error: 4 条(错误信息) - Warn: 1 条(警告信息)
- Add label selector to filter out EndpointSlices managed by endpointslicemirroring-controller - Prevent deletion attempts on non-managed EndpointSlices (avoid forbidden errors) - Update test case to match the new filtering logic - All tests passed with proto conflict policy ignore flag
- Add cleanup logic to remove legacy EndpointSlices when switching from EndpointSlice mode to Endpoints mode - Prevent duplicate data collection caused by leftover EndpointSlices - Filter only operator-managed EndpointSlices (exclude system-managed ones) - Add comprehensive logging for cleanup operations - Symmetric design with existing Endpoints cleanup in EndpointSlice mode
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.