-
Notifications
You must be signed in to change notification settings - Fork 81
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: fail to get podCIDR and serviceCIDR #4366
fix: fail to get podCIDR and serviceCIDR #4366
Conversation
原先的想法是使用 kubeadm 自带的 ClusterConfiguration 进行反序列化, 但是对于一些较低版本的 kubernetes, 需要兼容多个版本 v1beta1, v1beta2, v1beta3, v1beta4, 所以还是采取了字符串搜索的模式, 仅仅优化了查询逻辑, 和查询失败的降级逻辑 |
k8sPodCIDR, k8sServiceCIDR = ExtractK8sCIDRFromKubeadmConfigMap(&cm) | ||
logger.Sugar().Infof("kubeadm-config configMap k8sPodCIDR %v, k8sServiceCIDR %v", k8sPodCIDR, k8sServiceCIDR) | ||
} else { | ||
// 尝试从 kubeadm-config ConfigMap 获取 ClusterCIDR |
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.
代码注释统一风格,更应该是英文表达。
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.
感谢优化,代码 looks good to me, 几点小小的建议:
- 解决下 ci 的问题
- 可以为 ExtractK8sCIDRFromKubeadmConfigMap 函数添加一个 单元测试函数
k8sPodCIDR, k8sServiceCIDR = ExtractK8sCIDRFromKubeadmConfigMap(&cm) | ||
logger.Sugar().Infof("kubeadm-config configMap k8sPodCIDR %v, k8sServiceCIDR %v", k8sPodCIDR, k8sServiceCIDR) | ||
} else { | ||
// 尝试从 kubeadm-config ConfigMap 获取 ClusterCIDR |
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.
可以改下 英文注释
是的,这里使用字符串搜索的模式即可 |
另外请使用 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4366 +/- ##
==========================================
- Coverage 79.26% 6.80% -72.46%
==========================================
Files 54 59 +5
Lines 6283 7174 +891
==========================================
- Hits 4980 488 -4492
- Misses 1108 6651 +5543
+ Partials 195 35 -160
Flags with carried forward coverage won't be shown. Click here to find out more.
|
218a9d6
to
fb36fbe
Compare
CI 问题我不是很清楚具体是啥问题, 或者可以告诉我需要解决啥嘛 |
Error: ./spidercoordinator_test.go:467:28: assignment mismatch: 2 variables but coordinatormanager.ExtractK8sCIDRFromKubeadmConfigMap returns 3 values 变更了 ExtractK8sCIDRFromKubeadmConfigMap,导致返回值不匹配。应该同步更改一下 e2e case 。 |
fb36fbe
to
fc5fc86
Compare
我对于Ginkgo 不是很熟悉, 尝试往 e2e 测试中加入了一些 case , 不知道这么写是否符合规范 |
@@ -389,7 +390,77 @@ var _ = Describe("SpiderCoordinator", Label("spidercoordinator", "overlay"), Ser | |||
var masterNode string | |||
var err error | |||
|
|||
var clusterConfigurationInOneLineCm *corev1.ConfigMap |
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.
测试函数本身 就在函数文件内闭环即可, test 放的是 e2e 测试,更多是端到端的测试。所以把这部分挪到 pkg/coordinatormanager/coordinator_informer_test.go 就可
cm *corev1.ConfigMap | ||
} | ||
|
||
clusterConfigurationInOneLineJson := ` |
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.
这个 string 可以简化和输出友好一下,目前可读性有点差
fc5fc86
to
b36a7c1
Compare
@@ -464,7 +464,7 @@ var _ = Describe("SpiderCoordinator", Label("spidercoordinator", "overlay"), Ser | |||
It("Prioritize getting ClusterCIDR from kubeadm-config", Label("V00009"), func() { | |||
GinkgoWriter.Printf("podCIDR and serviceCIDR from spidercoordinator: %v,%v\n", spc.Status.OverlayPodCIDR, spc.Status.ServiceCIDR) | |||
|
|||
podCIDR, serviceCIDr := coordinatormanager.ExtractK8sCIDRFromKubeadmConfigMap(cm) | |||
podCIDR, serviceCIDr, _ := coordinatormanager.ExtractK8sCIDRFromKubeadmConfigMap(cm) |
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.
返回的 err 应该被判断一下,避免可能出现的 Extract 失败。
在 ginkgo 中,你可以这样写。
podCIDR, serviceCIDr, err := coordinatormanager.ExtractK8sCIDRFromKubeadmConfigMap(cm)
Expect(err).NotTo(HaveOccurred(), "Failed to extract k8s CIDR from Kubeadm configMap, error is %v", err)
b36a7c1
to
e22466c
Compare
|
a2f578f
to
f454073
Compare
已修改 |
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.
Thanks! The codes look good!
good job |
the unit test failed: There were failures detected in the following suites: Test Suite Failed |
我晚点来处理一下 |
are there any updates ? thanks @0x0034 |
so sorry, I need to deal with OKR recently, I got it done this week |
Hi @0x0034, There is a small error. I'm sure it won't take too long to fix it. Today, we are planning a new release that will hopefully include this fix. Do you have time to help out with updating the PR? Or can you open your repository permissions to me so that I can change them for you?
|
fdce08e
to
84b8283
Compare
|
|
84b8283
to
0bf425a
Compare
Signed-off-by: ruochen <[email protected]> Signed-off-by: Cyclinder Kuo <[email protected]>
0bf425a
to
5a5a2c1
Compare
fix: fail to get podCIDR and serviceCIDR Signed-off-by: robot <[email protected]>
Thanks for contributing!
Notice:
"release/none"
"release/bug"
"release/feature"
What issue(s) does this PR fix:
Fixes #
Special notes for your reviewer: