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

refactor: remove cri wrapper #2613

Merged
merged 2 commits into from
Jan 13, 2019

Conversation

zhuangqh
Copy link
Contributor

@zhuangqh zhuangqh commented Dec 25, 2018

Signed-off-by: zhuangqh zhuangqhc@gmail.com

Ⅰ. Describe what this PR did

using grpc interceptor to hook each grpc connection logging.

Ⅱ. Does this pull request fix one issue?

related to #2633

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

grpc logging like

$ crictl runp pod.json
INFO[2018-12-29T06:27:33.784753333Z] grpc start                                    grpc.method=RunPodSandbox grpc.request.content=&RunPodSandboxRequest{Config:&PodSandboxConfig{Metadata:&PodSandboxMetadata{Name:nginx-sandbox,Uid:hdishd83djaidwnduwk28bnnb,Namespace:default,Attempt:1,},Hostname:,LogDirectory:,DnsConfig:nil,PortMappings:[],Labels:map[string]string{},Annotations:map[string]string{},Linux:nil,},RuntimeHandler:,} grpc.service=runtime.v1alpha2.RuntimeService grpc.start_time="2018-12-29T06:27:33Z"
INFO[2018-12-29T06:27:33.78831053Z] invoke container pre-create hook in plugin
INFO[2018-12-29T06:27:33.799896345Z] write mtab file to (/var/lib/pouch/containers/e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062/rootfs/etc/mtab)
WARN[2018-12-29T06:27:33.812157386Z] get passwd file or group file is nil
INFO[2018-12-29T06:27:33.812893641Z] success to get image registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0, container id e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062
INFO[2018-12-29T06:27:33.819013058Z] success to new container: e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062
INFO[2018-12-29T06:27:33.821998625Z] shim containerd-shim started                  address="/containerd-shim/default/e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062/shim.sock" debug=false pid=8279
INFO[2018-12-29T06:27:33.986153234Z] success to create task(pid=8295) in container(e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062)
INFO[2018-12-29T06:27:34.017795534Z] success to start task in container(e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062)
INFO[2018-12-29T06:27:34.017824179Z] success to add container, id: e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062
INFO[2018-12-29T06:27:34.02161777Z] Got pod network &{Name:nginx-sandbox Namespace:default ID:e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062 NetNS:/proc/8295/ns/net PortMappings:[] Networks:[]}
INFO[2018-12-29T06:27:34.02164234Z] About to add CNI network cni-loopback (type=loopback)
INFO[2018-12-29T06:27:34.024564394Z] Got pod network &{Name:nginx-sandbox Namespace:default ID:e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062 NetNS:/proc/8295/ns/net PortMappings:[] Networks:[]}
INFO[2018-12-29T06:27:34.024578428Z] About to add CNI network mynet (type=bridge)
INFO[2018-12-29T06:27:34.06731512Z] grpc end                                      grpc.method=RunPodSandbox grpc.response.content=&RunPodSandboxResponse{PodSandboxId:e2141b5bc3561bd6f43b3acafb047b44c2dddabaecd1ce2fad164e4adab28062,} grpc.service=runtime.v1alpha2.RuntimeService grpc.start_time="2018-12-29T06:27:33Z"

fails

INFO[2018-12-29T06:29:20.786531364Z] grpc start                                    grpc.method=StartContainer grpc.request.content=&StartContainerRequest{ContainerId:kk,} grpc.service=runtime.v1alpha2.RuntimeService grpc.start_time="2018-12-29T06:29:20Z"
ERRO[2018-12-29T06:29:20.786615725Z] grpc failed failed to start container "kk": container kk: not found  grpc.method=StartContainer grpc.response.content=nil grpc.service=runtime.v1alpha2.RuntimeService grpc.start_time="2018-12-29T06:29:20Z"

for read only interface, such as crictl pods. Just print debug log.

DEBU[2018-12-29T06:26:21.95956152Z] Get a grpc client                             elapsed=4.363µs
DEBU[2018-12-29T06:26:21.960201681Z] Get a grpc client                             elapsed=957ns
DEBU[2018-12-29T06:26:21.96054135Z] Get a grpc client                             elapsed=804ns
DEBU[2018-12-29T06:26:21.960884243Z] Get a grpc client                             elapsed=916ns
DEBU[2018-12-29T06:26:21.96122824Z] Get a grpc client                             elapsed=864ns
DEBU[2018-12-29T06:26:21.961491604Z] Get a grpc client                             elapsed=880ns
DEBU[2018-12-29T06:26:24.979544613Z] grpc start                                    grpc.method=ListPodSandbox grpc.request.content=&ListPodSandboxRequest{Filter:&PodSandboxFilter{Id:,State:nil,LabelSelector:map[string]string{},},} grpc.service=runtime.v1alpha2.RuntimeService grpc.start_time="2018-12-29T06:26:24Z"
DEBU[2018-12-29T06:26:24.979874962Z] grpc end                                      grpc.method=ListPodSandbox grpc.response.content=&ListPodSandboxResponse{Items:[&PodSandbox{Id:1c9f76075695fcbde3d42accbb0d18deb0d8a0d0a96d2b0ffe4a52c6999370bc,Metadata:&PodSandboxMetadata{Name:nginx-sandbox,Uid:hdishd83djaidwnduwk28bnnb,Namespace:default,Attempt:1,},State:SANDBOX_READY,CreatedAt:1546064756398390025,Labels:map[string]string{},Annotations:map[string]string{},}],} grpc.service=runtime.v1alpha2.RuntimeService grpc.start_time="2018-12-29T06:26:24Z"
DEBU[2018-12-29T06:26:31.959004098Z] Get a grpc client                             elapsed=4.631µs
DEBU[2018-12-29T06:26:31.959648315Z] Get a grpc client                             elapsed=902ns
DEBU[2018-12-29T06:26:31.960007343Z] Get a grpc client                             elapsed=880ns
DEBU[2018-12-29T06:26:31.960351277Z] Get a grpc client                             elapsed=1.188µs
DEBU[2018-12-29T06:26:31.960710469Z] Get a grpc client                             elapsed=812ns
DEBU[2018-12-29T06:26:31.960971361Z] Get a grpc client                             elapsed=844ns

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Dec 25, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@22bfd53). Click here to learn what that means.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2613   +/-   ##
=========================================
  Coverage          ?   69.54%           
=========================================
  Files             ?      278           
  Lines             ?    18642           
  Branches          ?        0           
=========================================
  Hits              ?    12965           
  Misses            ?     4238           
  Partials          ?     1439
Flag Coverage Δ
#criv1alpha1test 31.57% <0%> (?)
#criv1alpha2test 35.52% <61.36%> (?)
#integrationtest 42.14% <0%> (?)
#nodee2etest 32.52% <61.36%> (?)
#unittest 27.27% <19.14%> (?)
Impacted Files Coverage Δ
cri/v1alpha2/types/sandbox_meta.go 100% <ø> (ø)
cri/v1alpha1/cri.go 59.43% <0%> (ø)
cri/criservice.go 56.62% <100%> (ø)
cri/v1alpha2/stream_server.go 79.2% <100%> (ø)
cri/v1alpha2/cri.go 67.53% <66.66%> (ø)
cri/v1alpha2/cri_utils.go 88.44% <68%> (ø)
pkg/utils/utils.go 83.26% <69.23%> (ø)
pkg/grpc/interceptor/logging.go 72.97% <72.97%> (ø)
cri/v1alpha2/service.go 93.1% <93.1%> (ø)

@zhuangqh zhuangqh force-pushed the refactor-cri-misc branch 8 times, most recently from 66429ab to a4ff7a0 Compare December 26, 2018 12:23
@zhuangqh zhuangqh changed the title [WIP] refactor: remove cri wrapper refactor: remove cri wrapper Dec 26, 2018
@starnop
Copy link
Contributor

starnop commented Dec 28, 2018

  1. Code refactoring
  2. GRPC logging interceptor

Maybe we should split it in a similar situation next time.
Whatever, LGTM. 😄

- simplify NewStreamServer
- move common util to pkg/utils

Signed-off-by: zhuangqh <zhuangqhc@gmail.com>
@zhuangqh zhuangqh force-pushed the refactor-cri-misc branch 3 times, most recently from 29618d6 to 233e1f8 Compare December 29, 2018 07:26
@zhuangqh
Copy link
Contributor Author

  1. Code refactoring
  2. GRPC logging interceptor

Maybe we should split it in a similar situation next time.
Whatever, LGTM. 😄

Has split them into two parts. remove the time cost log for every interface. @starnop

@starnop
Copy link
Contributor

starnop commented Jan 2, 2019

Got it, and LGTM again. 😄

Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

Just a suggestion for updating vendor: maybe we can provide the govendor command in git commit so that we can see how to update vendor.

},
{
"checksumSHA1": "Z4RIWIXH05QItZqVbmbONO9mWig=",
"checksumSHA1": "G0aiY+KmzFsQLTNzRAGRhJNSj7A=",
"path": "github.com/golang/protobuf/ptypes/any",
Copy link
Contributor

Choose a reason for hiding this comment

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

containerd current master uses github.com/golang/protobuf@v1.1.0. I am not sure that it is conflicting item when we update containerd. If it is conflicting, we can implement WithUnaryServerChain by ourself.

pkg/grpc/interceptor/logging.go Show resolved Hide resolved
cri/v1alpha2/service.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

please repush to re-trigger travis-ci. thanks!

Signed-off-by: zhuangqh <zhuangqhc@gmail.com>
@HusterWan
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Jan 10, 2019
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/cri areas/log kind/refactor LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants