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 parsing logical router static routes #2443

Merged
merged 3 commits into from Mar 8, 2023

Conversation

zhangzujian
Copy link
Member

What type of this PR

  • Bug fixes

Which issue(s) this PR fixes:

Fixes #(issue-number)

@zhangzujian zhangzujian marked this pull request as ready for review March 8, 2023 04:24
@hongzhen-ma
Copy link
Collaborator

@hongzhen-ma
Copy link
Collaborator

可以再跟 @bobz965 确认下

@zhangzujian
Copy link
Member Author

@bobz965

--- FAIL: Test_parseLrRouteListOutput (0.00s)
panic: runtime error: index out of range [4] with length 4 [recovered]
	panic: runtime error: index out of range [4] with length 4

goroutine 1237 [running]:
testing.tRunner.func1.2({0x16[450](https://github.com/kubeovn/kube-ovn/actions/runs/4360712653/jobs/7623900996#step:7:451)00, 0xc000887128})
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1526 +0x24e
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1529 +0x39f
panic({0x1645000, 0xc000887128})
	/opt/hostedtoolcache/go/1.20.1/x64/src/runtime/panic.go:884 +0x213
github.com/kubeovn/kube-ovn/pkg/ovs.parseLrRouteListOutput({0x17d0894?, 0x1523d40?})
	/home/runner/work/kube-ovn/kube-ovn/pkg/ovs/ovn-nbctl-legacy.go:1199 +0x41d
github.com/kubeovn/kube-ovn/pkg/ovs.Test_parseLrRouteListOutput(0xc000a231e0?)
	/home/runner/work/kube-ovn/kube-ovn/pkg/ovs/ovn-nbctl-legacy_test.go:29 +0xac
testing.tRunner(0xc000a23380, 0x1818e98)
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1576 +0x10b
created by testing.(*T).Run
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1629 +0x3ea

@zhangzujian zhangzujian removed the request for review from oilbeater March 8, 2023 05:18
@bobz965
Copy link
Collaborator

bobz965 commented Mar 8, 2023

@bobz965

--- FAIL: Test_parseLrRouteListOutput (0.00s)
panic: runtime error: index out of range [4] with length 4 [recovered]
	panic: runtime error: index out of range [4] with length 4

goroutine 1237 [running]:
testing.tRunner.func1.2({0x16[450](https://github.com/kubeovn/kube-ovn/actions/runs/4360712653/jobs/7623900996#step:7:451)00, 0xc000887128})
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1526 +0x24e
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1529 +0x39f
panic({0x1645000, 0xc000887128})
	/opt/hostedtoolcache/go/1.20.1/x64/src/runtime/panic.go:884 +0x213
github.com/kubeovn/kube-ovn/pkg/ovs.parseLrRouteListOutput({0x17d0894?, 0x1523d40?})
	/home/runner/work/kube-ovn/kube-ovn/pkg/ovs/ovn-nbctl-legacy.go:1199 +0x41d
github.com/kubeovn/kube-ovn/pkg/ovs.Test_parseLrRouteListOutput(0xc000a231e0?)
	/home/runner/work/kube-ovn/kube-ovn/pkg/ovs/ovn-nbctl-legacy_test.go:29 +0xac
testing.tRunner(0xc000a23380, 0x1818e98)
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1576 +0x10b
created by testing.(*T).Run
	/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1629 +0x3ea
[root@pc-node-1 pc-3-node-test-eip-snat]# k ko nbctl lr-route-list ovn-cluster
IPv4 Routes
Route Table <main>:
                0.0.0.0/0              10.5.204.254 dst-ip
[root@pc-node-1 pc-3-node-test-eip-snat]#
[root@pc-node-1 pc-3-node-test-eip-snat]# k ko nbctl lr-route-list vpc1
IPv4 Routes
Route Table <main>:
           192.168.0.0/24              10.5.204.103 src-ip ecmp ecmp-symmetric-reply bfd
           192.168.0.0/24              10.5.204.104 src-ip ecmp ecmp-symmetric-reply bfd
           192.168.0.0/24              10.5.204.105 src-ip ecmp ecmp-symmetric-reply bfd

在bfd 静态路由的场景中,目的要取第5个值,也就是序列为4. 此时长度应该为6
之前我以为路由的分割大概只有两种,现在看可能不是。 或许可以将那个条件 <4, 改为小于5,或者小于6?

@zhangzujian
Copy link
Member Author

According to the OVN source code, the output format of the command lr-route-list is:

<PREFIX> <NEXT_HOP> <POLICY> [OUTPUT_PORT] [(learned)] [ecmp] [ecmp-symmetric-reply] [bfd]

@zhangzujian zhangzujian changed the title fix index out of range fix parsing logical router static routes Mar 8, 2023
@zhangzujian zhangzujian marked this pull request as draft March 8, 2023 05:38
@bobz965
Copy link
Collaborator

bobz965 commented Mar 8, 2023

According to the OVN source code, the output format of the command lr-route-list is:

<PREFIX> <NEXT_HOP> <POLICY> [OUTPUT_PORT] [(learned)] [ecmp] [ecmp-symmetric-reply] [bfd]

如果有类似数据库字段的读取方式就好了,目前的命令行式输出的结果不太好确定总长度。 可能需要穷举当前的静态路由的使用场景才可以有效确定需要的值在哪一位次。如果后续引入新的使用场景,可能还得调整。

@zhangzujian zhangzujian requested a review from bobz965 March 8, 2023 06:44
@zhangzujian zhangzujian marked this pull request as ready for review March 8, 2023 06:48
Copy link
Collaborator

@bobz965 bobz965 left a comment

Choose a reason for hiding this comment

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

LGTM!

@zhangzujian zhangzujian merged commit b399cca into kubeovn:master Mar 8, 2023
@zhangzujian zhangzujian deleted the fix-index branch March 8, 2023 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants