cloud-org / edge-proxy

2022第三届云原生编程挑战赛-赛道2:针对边缘计算场景的ACK@Edge高效的边缘自治方案 队伍: 唔想返工
6 stars 1 forks source link

解题思路 #1

Closed ronething-bot closed 2 years ago

ronething-bot commented 2 years ago
ronething-bot commented 2 years ago
ronething-bot commented 2 years ago
ronething-bot commented 2 years ago
ronething commented 2 years ago
ronething commented 2 years ago
ronething-bot commented 2 years ago
  • 一致性问题,会使用 proxyClient create 资源对象,评测程序貌似会对 kube-apiserver 进行 watch 调用,具体可以测测。

经过测试,如果 proxy 返回不了数据,则会进行 watch,所以正常返回数据即可。

ronething-bot commented 2 years ago
handler = yurthubutil.WithRequestContentType(handler)
handler = WithCacheHeaderCheck(handler)
handler = WithListRequestSelector(handler)

// inject request info
handler = filters.WithRequestInfo(handler, d.resolver)

接下来就是资源占用率优化的问题。先 close

ronething commented 2 years ago

经过测试,如果 proxy 返回不了数据,则会进行 watch,所以正常返回数据即可。

这里的 watch,其实是由于 benchmark 实例化了 proxy informer 发起的,而不是 list request 重新发起。

I0817 23:37:03.369759 3970440 handler.go:101] request is &{Method:GET URL:/api/v1/namespaces/default/configmaps?labelSelector=cloud-native-challenge%3Dbenchmark%2Ctype%3Dconsistency Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept:[application/json, */*] Accept-Encoding:[gzip] User-Agent:[benchmark/v0.0.0 (linux/amd64) kubernetes/$Format]] Body:{} GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:127.0.0.1:10261 Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:56150 RequestURI:/api/v1/namespaces/default/configmaps?labelSelector=cloud-native-challenge%3Dbenchmark%2Ctype%3Dconsistency TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc00015a6c0}
2022/08/17 23:37:18 httputil: ReverseProxy read error during body copy: http2: client connection lost
E0817 23:37:18.366065 3970440 remote.go:65] remote proxy error handler: https://192.168.49.2:8443/api/v1/namespaces/default/configmaps?labelSelector=cloud-native-challenge%3Dbenchmark%2Ctype%3Dconsistency, http2: client connection lost

# 注意这里多了个 watch 请求,就是由 proxy informer 发起的,对应下文 benchmark 端日志
I0817 23:37:18.366346 3970440 handler.go:101] request is &{Method:GET URL:/api/v1/configmaps?allowWatchBookmarks=true&resourceVersion=1550475&timeout=5m27s&timeoutSeconds=327&watch=true Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept:[application/json, */*] Accept-Encoding:[gzip] User-Agent:[benchmark/v0.0.0 (linux/amd64) kubernetes/$Format]] Body:{} GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:127.0.0.1:10261 Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:56150 RequestURI:/api/v1/configmaps?allowWatchBookmarks=true&resourceVersion=1550475&timeout=5m27s&timeoutSeconds=327&watch=true TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc0005060c0}
E0817 23:37:48.366893 3970440 remote.go:65] remote proxy error handler: https://192.168.49.2:8443/api/v1/configmaps?allowWatchBookmarks=true&resourceVersion=1550475&timeout=5m27s&timeoutSeconds=327&watch=true, dial tcp 192.168.49.2:8443: i/o timeout
I0817 23:37:49.834858 3970440 handler.go:101] request is &{Method:GET URL:/api/v1/configmaps?resourceVersion=1550475 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept:[application/json, */*] Accept-Encoding:[gzip] User-Agent:[benchmark/v0.0.0 (linux/amd64) kubernetes/$Format]] Body:{} GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:127.0.0.1:10261 Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:56150 RequestURI:/api/v1/configmaps?resourceVersion=1550475 TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc000506440}
E0817 23:38:18.372145 3970440 remote.go:65] remote proxy error handler: https://192.168.49.2:8443/api/v1/configmaps?resourceVersion=1550475, context canceled
➜  amd64 git:(master) ✗ ./benchmark --namespace ${ns} --use-kubeconfig --bench consistency                                                                                      
I0817 23:36:28.027713 3970788 start.go:61] Version:projectinfo.Info{GitVersion:"v0.1.0", GitCommit:"b7e788f", BuildDate:"2022-08-17T15:35:54Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}
I0817 23:36:28.027760 3970788 start.go:113] Sleep 1 minute to wait edge-proxy ready
I0817 23:36:33.041220 3970788 benchmark.go:102] Proxy informer factory prepare to start ...
I0817 23:36:33.041283 3970788 benchmark.go:104] Proxy informer started
I0817 23:36:33.141717 3970788 benchmark.go:109] Proxy informer wait for cache synced
I0817 23:36:33.228219 3970788 benchmark.go:155] ######## Start to benchMark consistency ########
E0817 23:36:33.368213 3970788 benchmark-consistency.go:96] exec iptables -I OUTPUT -p tcp --dport 6443 -j DROP error exit status 4
I0817 23:36:33.368230 3970788 benchmark-consistency.go:97] you should manually exec cmd: iptables -I OUTPUT -p tcp --dport 6443 -j DROP
I0817 23:36:33.368235 3970788 benchmark-consistency.go:100] exec iptables -I OUTPUT -p tcp --dport 6443 -j DROP output Fatal: can't open lock file /run/xtables.lock: Permission denied
E0817 23:37:18.366201 3970788 benchmark-consistency.go:117] benchMark consistency proxy list cms error an error on the server ("") has prevented the request from succeeding (get configmaps)
E0817 23:37:18.366223 3970788 benchmark.go:163] benchMark consistency error an error on the server ("") has prevented the request from succeeding (get configmaps)

# proxy informer watch configmaps 失败
E0817 23:37:48.367333 3970788 reflector.go:138] pkg/mod/k8s.io/client-go@v0.22.3/tools/cache/reflector.go:167: Failed to watch *v1.ConfigMap: an error on the server ("") has prevented the request from succeeding (get configmaps)
I0817 23:38:18.366493 3970788 benchmark.go:175] -------- All benchmark exec end --------