alibaba / kt-connect

A toolkit for Integrating with your kubernetes dev environment more efficiently
https://alibaba.github.io/kt-connect/#/
GNU General Public License v3.0
1.52k stars 230 forks source link

启动时设置route规则报错 #320

Closed CoderTDK closed 2 years ago

CoderTDK commented 2 years ago

sudo ktctl connect Password: 10:43AM INF Using cluster context kubernetes-admin@kubernetes (kubernetes) 10:43AM INF KtConnect 0.3.5 start at 40422 (darwin amd64) 10:43AM INF Fetching cluster time ... 10:43AM INF Using tun2socks mode 10:43AM INF Successful create config map kt-connect-shadow-tfzcu 10:43AM INF Deploying shadow pod kt-connect-shadow-tfzcu in namespace default 10:43AM INF Waiting for pod kt-connect-shadow-tfzcu ... 10:43AM INF Pod kt-connect-shadow-tfzcu is ready 10:43AM INF Port forward local:60734 -> pod kt-connect-shadow-tfzcu:22 established 10:43AM INF Socks proxy established 10:43AM INF Tun device utun2 is ready panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x210d057]

goroutine 1 [running]: github.com/alibaba/kt-connect/pkg/kt/command/connect.setupTunRoute() /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect/tun2socks.go:63 +0x137 github.com/alibaba/kt-connect/pkg/kt/command/connect.ByTun2Socks() /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect/tun2socks.go:45 +0x265 github.com/alibaba/kt-connect/pkg/kt/command.Connect() /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect.go:54 +0xfd github.com/alibaba/kt-connect/pkg/kt/command.NewConnectCommand.func2(0xc0003e7180?, {0x33d3fe8?, 0x0?, 0x0?}) /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect.go:31 +0x17 github.com/spf13/cobra.(Command).execute(0xc0003e7180, {0x33d3fe8, 0x0, 0x0}) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856 +0x67c github.com/spf13/cobra.(Command).ExecuteC(0xc0003e6f00) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4 github.com/spf13/cobra.(*Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902 main.main() /home/runner/work/kt-connect/kt-connect/cmd/ktctl/main.go:60 +0x2ef

linfan commented 2 years ago

问题收到,初步看下来是因为没有找到任何可设置路由的IP段,导致报了无可用路由的错误,同时错误内容为nil(因为并非是路由设置失败导致),最终变成了空指针引用异常。

这个异常会在下个版里处理掉,不过以上信息还无法看出为什么没有识别出可路由的IP段,能提供一下加上--debug参数运行的日志吗?

CoderTDK commented 2 years ago

sudo ktctl connect --debug Password: 2:24PM DBG Background task log to /tmp/kt-513936705 2:24PM INF Using cluster context kubernetes-admin@kubernetes (kubernetes) 2:24PM INF KtConnect 0.3.5 start at 49717 (darwin amd64) 2:24PM DBG Rectify pod kt-rectifier-jzwiu created 2:24PM INF Fetching cluster time ... 2:24PM DBG Execute command [date +%s] in kt-rectifier-jzwiu:standalone 2:24PM DBG No time difference 2:24PM INF Using tun2socks mode 2:24PM DBG Found local domains: cn.corp.seagroup.com 2:24PM DBG Find 2 kt pods 2:24PM DBG * pod kt-connect-shadow-tfzcu expired, lastHeartBeat: 1654829004 2:24PM DBG role shadow-connect, config: map[] 2:24PM DBG Private Key generated 2:24PM DBG Public key generated 2:24PM INF Successful create config map kt-connect-shadow-ppbuh 2:24PM INF Deploying shadow pod kt-connect-shadow-ppbuh in namespace default 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Waiting for pod kt-connect-shadow-ppbuh ... 2:24PM INF Pod kt-connect-shadow-ppbuh is ready 2:24PM DBG Using port 39744 2:24PM DBG Request port forward pod:22 -> local:39744 via https://apiserver.kube-xxx-sz-dev.k8s.cluster:6443 2:24PM INF Port forward local:39744 -> pod kt-connect-shadow-ppbuh:22 established 2:24PM INF Socks proxy established 2:25PM INF Tun device utun2 is ready 2:25PM DBG Service CIDR are: [10.12.253.0/24] 2:25PM DBG Cluster CIDR are: [10.12.0.0/16] 2:25PM DBG Using cluster ip 10.12.208.199 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x210d057]

goroutine 1 [running]: github.com/alibaba/kt-connect/pkg/kt/command/connect.setupTunRoute() /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect/tun2socks.go:63 +0x137 github.com/alibaba/kt-connect/pkg/kt/command/connect.ByTun2Socks() /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect/tun2socks.go:45 +0x265 github.com/alibaba/kt-connect/pkg/kt/command.Connect() /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect.go:54 +0xfd github.com/alibaba/kt-connect/pkg/kt/command.NewConnectCommand.func2(0xc0004db180?, {0xc0004e8240?, 0x1?, 0x1?}) /home/runner/work/kt-connect/kt-connect/pkg/kt/command/connect.go:31 +0x17 github.com/spf13/cobra.(Command).execute(0xc0004db180, {0xc0004e8230, 0x1, 0x1}) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856 +0x67c github.com/spf13/cobra.(Command).ExecuteC(0xc0004daf00) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4 github.com/spf13/cobra.(*Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902 main.main() /home/runner/work/kt-connect/kt-connect/cmd/ktctl/main.go:60 +0x2ef

这个是加了debug后的日志哈

linfan commented 2 years ago

已在v0.3.6版本优化了路由合并逻辑,包含针对此问题的修复