Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit f933b46

Browse files
committed
serverrpc: remove duplicated logs
After bd66e67 (serverrpc.NewServerRPC: set unaryLoger and streamLoger as grpc interceptors), most of grpc log can be outputted in unaryLoger and streamLoger. Remove duplicated logs. Signed-off-by: Hui Zhu <[email protected]>
1 parent bd66e67 commit f933b46

File tree

11 files changed

+3
-152
lines changed

11 files changed

+3
-152
lines changed

Diff for: serverrpc/attach.go

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ func (s *ServerRPC) Attach(stream types.PublicAPI_AttachServer) error {
1414
if err != nil {
1515
return err
1616
}
17-
glog.V(3).Infof("Attach with request %s", req.String())
1817

1918
ir, iw := io.Pipe()
2019
or, ow := io.Pipe()

Diff for: serverrpc/container.go

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,66 @@
11
package serverrpc
22

33
import (
4-
"github.com/golang/glog"
54
"github.com/hyperhq/hyperd/types"
65
"golang.org/x/net/context"
76
)
87

98
// ContainerCreate creates a container by UserContainer spec
109
func (s *ServerRPC) ContainerCreate(ctx context.Context, req *types.ContainerCreateRequest) (*types.ContainerCreateResponse, error) {
11-
glog.V(3).Infof("ContainerCreate with request %s", req.String())
12-
1310
containerID, err := s.daemon.CreateContainerInPod(req.PodID, req.ContainerSpec)
1411
if err != nil {
15-
glog.Errorf("ContainerCreate failed %v with request %s: %v", err, req.String())
1612
return nil, err
1713
}
1814

19-
glog.V(3).Infof("ContainerCreate done with request %s", req.String())
20-
2115
return &types.ContainerCreateResponse{
2216
ContainerID: containerID,
2317
}, nil
2418
}
2519

2620
func (s *ServerRPC) ContainerStart(ctx context.Context, req *types.ContainerStartRequest) (*types.ContainerStartResponse, error) {
27-
glog.V(3).Info("ContainerStart with request %s", req.String())
2821
err := s.daemon.StartContainer(req.ContainerId)
2922
if err != nil {
30-
glog.Errorf("ContainerStart failed %v with request %s", err, req.String())
3123
return nil, err
3224
}
33-
glog.V(3).Info("ContainerStart done with request %s", req.String())
25+
3426
return &types.ContainerStartResponse{}, nil
3527
}
3628

3729
// ContainerStop implements POST /container/stop
3830
func (s *ServerRPC) ContainerStop(c context.Context, req *types.ContainerStopRequest) (*types.ContainerStopResponse, error) {
39-
glog.V(3).Infof("ContainerStop with request %v", req.String())
40-
4131
err := s.daemon.StopContainer(req.ContainerID, int(req.Timeout))
4232
if err != nil {
43-
glog.Errorf("ContainerStop failed %v with request %v", err, req.String())
4433
return nil, err
4534
}
4635

47-
glog.V(3).Infof("ContainerStop done with request %v", req.String())
48-
4936
return &types.ContainerStopResponse{}, nil
5037
}
5138

5239
// ContainerRename rename a container
5340
func (s *ServerRPC) ContainerRename(c context.Context, req *types.ContainerRenameRequest) (*types.ContainerRenameResponse, error) {
54-
glog.V(3).Infof("ContainerRename with request %v", req.String())
55-
5641
err := s.daemon.ContainerRename(req.OldContainerName, req.NewContainerName)
5742
if err != nil {
58-
glog.Errorf("ContainerRename failed %v with request %v", err, req.String())
5943
return nil, err
6044
}
6145

62-
glog.V(3).Infof("ContainerRename done with request %v", req.String())
63-
6446
return &types.ContainerRenameResponse{}, nil
6547
}
6648

6749
func (s *ServerRPC) ContainerRemove(ctx context.Context, req *types.ContainerRemoveRequest) (*types.ContainerRemoveResponse, error) {
68-
glog.V(3).Info("ContainerRemove with request %s", req.String())
6950
err := s.daemon.RemoveContainer(req.ContainerId)
7051
if err != nil {
71-
glog.Errorf("ContainerRemove failed %v with request %s", err, req.String())
7252
return nil, err
7353
}
74-
glog.V(3).Info("ContainerRemove done with request %s", req.String())
54+
7555
return &types.ContainerRemoveResponse{}, nil
7656
}
7757

7858
// ContainerSignal sends a singal to specified container of specified pod
7959
func (s *ServerRPC) ContainerSignal(ctx context.Context, req *types.ContainerSignalRequest) (*types.ContainerSignalResponse, error) {
80-
glog.V(3).Infof("ContainerSignal with request %s", req.String())
81-
8260
err := s.daemon.KillPodContainers(req.PodID, req.ContainerID, req.Signal)
8361
if err != nil {
84-
glog.Errorf("ContainerSignal failed %v done with request %s", err, req.String())
8562
return nil, err
8663
}
8764

88-
glog.V(3).Infof("ContainerSignal done with request %s", req.String())
8965
return &types.ContainerSignalResponse{}, nil
9066
}

Diff for: serverrpc/exec.go

-14
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,16 @@ import (
1111
)
1212

1313
func (s *ServerRPC) ExecCreate(ctx context.Context, req *types.ExecCreateRequest) (*types.ExecCreateResponse, error) {
14-
glog.V(3).Infof("ExecCreate with request %s", req.String())
15-
1614
cmd, err := json.Marshal(req.Command)
1715
if err != nil {
1816
return nil, err
1917
}
2018

2119
execId, err := s.daemon.CreateExec(req.ContainerID, string(cmd), req.Tty)
2220
if err != nil {
23-
glog.Errorf("ExecCreate failed %v with request %s", err, req.String())
24-
2521
return nil, err
2622
}
2723

28-
glog.V(3).Infof("ExecCreate done with request %s", req.String())
29-
3024
return &types.ExecCreateResponse{
3125
ExecID: execId,
3226
}, nil
@@ -95,32 +89,24 @@ func (s *ServerRPC) ExecStart(stream types.PublicAPI_ExecStartServer) error {
9589

9690
// Wait gets exitcode by container and processId
9791
func (s *ServerRPC) Wait(c context.Context, req *types.WaitRequest) (*types.WaitResponse, error) {
98-
glog.V(3).Infof("Wait with request %s", req.String())
99-
10092
//FIXME need update if param NoHang is enabled
10193
code, err := s.daemon.ExitCode(req.Container, req.ProcessId)
10294
if err != nil {
103-
glog.Errorf("Wait failed %v with request %s", err, req.String())
10495
return nil, err
10596
}
10697

107-
glog.V(3).Infof("Wait done with request %s", req.String())
10898
return &types.WaitResponse{
10999
ExitCode: int32(code),
110100
}, nil
111101
}
112102

113103
// ExecSignal sends a singal to specified exec of specified container
114104
func (s *ServerRPC) ExecSignal(ctx context.Context, req *types.ExecSignalRequest) (*types.ExecSignalResponse, error) {
115-
glog.V(3).Infof("ExecSignal with request %s", req.String())
116-
117105
err := s.daemon.KillExec(req.ContainerID, req.ExecID, req.Signal)
118106
if err != nil {
119-
glog.Errorf("ExecSignal failed %v with request %s", err, req.String())
120107
return nil, err
121108
}
122109

123-
glog.V(3).Infof("ExecSignal done with request %s", req.String())
124110
return &types.ExecSignalResponse{}, nil
125111
}
126112

Diff for: serverrpc/images.go

-14
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ import (
1313

1414
// ImageList implements GET /images/get
1515
func (s *ServerRPC) ImageList(ctx context.Context, req *types.ImageListRequest) (*types.ImageListResponse, error) {
16-
glog.V(3).Infof("ImageList with request %s", req.String())
17-
1816
images, err := s.daemon.Daemon.Images(req.FilterArgs, req.Filter, req.All)
1917
if err != nil {
20-
glog.Errorf("ImageList failed %v with request %s", err, req.String())
2118
return nil, err
2219
}
2320

@@ -34,16 +31,13 @@ func (s *ServerRPC) ImageList(ctx context.Context, req *types.ImageListRequest)
3431
})
3532
}
3633

37-
glog.V(3).Infof("ImageList done with request %s", req.String())
3834
return &types.ImageListResponse{
3935
ImageList: result,
4036
}, nil
4137
}
4238

4339
// ImagePull pulls a image from registry
4440
func (s *ServerRPC) ImagePull(req *types.ImagePullRequest, stream types.PublicAPI_ImagePullServer) error {
45-
glog.V(3).Infof("ImagePull with request %s", req.String())
46-
4741
authConfig := &enginetypes.AuthConfig{}
4842
if req.Auth != nil {
4943
authConfig = &enginetypes.AuthConfig{
@@ -89,14 +83,11 @@ func (s *ServerRPC) ImagePull(req *types.ImagePullRequest, stream types.PublicAP
8983
pullResult = s.daemon.CmdImagePull(req.Image, req.Tag, authConfig, nil, w)
9084
complete = true
9185

92-
glog.V(3).Infof("ImagePull done with request %s", req.String())
9386
return pullResult
9487
}
9588

9689
// ImagePush pushes a local image to registry
9790
func (s *ServerRPC) ImagePush(req *types.ImagePushRequest, stream types.PublicAPI_ImagePushServer) error {
98-
glog.V(3).Infof("ImagePush with request %s", req.String())
99-
10091
authConfig := &enginetypes.AuthConfig{}
10192
if req.Auth != nil {
10293
authConfig = &enginetypes.AuthConfig{
@@ -137,21 +128,16 @@ func (s *ServerRPC) ImagePush(req *types.ImagePushRequest, stream types.PublicAP
137128
}
138129
}
139130

140-
glog.V(3).Infof("ImagePush done with request %s", req.String())
141131
return pushResult
142132
}
143133

144134
// ImageRemove deletes a image from hyperd
145135
func (s *ServerRPC) ImageRemove(ctx context.Context, req *types.ImageRemoveRequest) (*types.ImageRemoveResponse, error) {
146-
glog.V(3).Infof("ImageDelete with request %s", req.String())
147-
148136
resp, err := s.daemon.CmdImageDelete(req.Image, req.Force, req.Prune)
149137
if err != nil {
150-
glog.Errorf("ImageDelete failed %v with request %s", err, req.String())
151138
return nil, err
152139
}
153140

154-
glog.V(3).Infof("ImageDelete done with request %s", req.String())
155141
return &types.ImageRemoveResponse{
156142
Images: resp,
157143
}, nil

Diff for: serverrpc/info.go

-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package serverrpc
22

33
import (
4-
"github.com/golang/glog"
54
"github.com/hyperhq/hyperd/types"
65
"github.com/hyperhq/hyperd/utils"
76
"golang.org/x/net/context"
@@ -13,47 +12,35 @@ const (
1312

1413
// PodInfo gets PodInfo by podID
1514
func (s *ServerRPC) PodInfo(c context.Context, req *types.PodInfoRequest) (*types.PodInfoResponse, error) {
16-
glog.V(3).Infof("PodInfo with request %s", req.String())
17-
1815
info, err := s.daemon.GetPodInfo(req.PodID)
1916
if err != nil {
20-
glog.Errorf("PodInfo failed %v with request %s", err, req.String())
2117
return nil, err
2218
}
2319

24-
glog.V(3).Infof("PodInfo done with request %s info %+v", req.String(), info)
2520
return &types.PodInfoResponse{
2621
PodInfo: info,
2722
}, nil
2823
}
2924

3025
// ContainerInfo gets ContainerInfo by ID or name of container
3126
func (s *ServerRPC) ContainerInfo(c context.Context, req *types.ContainerInfoRequest) (*types.ContainerInfoResponse, error) {
32-
glog.V(3).Infof("ContainerInfo with request %s", req.String())
33-
3427
info, err := s.daemon.GetContainerInfo(req.Container)
3528
if err != nil {
36-
glog.Errorf("ContainerInfo failed %v with request %s", err, req.String())
3729
return nil, err
3830
}
3931

40-
glog.V(3).Infof("ContainerInfo done with request %s info %+v", req.String(), info)
4132
return &types.ContainerInfoResponse{
4233
ContainerInfo: info,
4334
}, nil
4435
}
4536

4637
// Info gets CmdSystemInfo
4738
func (s *ServerRPC) Info(c context.Context, req *types.InfoRequest) (*types.InfoResponse, error) {
48-
glog.V(3).Infof("Info with request %s", req.String())
49-
5039
info, err := s.daemon.CmdSystemInfo()
5140
if err != nil {
52-
glog.Errorf("Info failed %v with request %s", err, req.String())
5341
return nil, err
5442
}
5543

56-
glog.V(3).Infof("Info done with request %s", req.String())
5744
return info, nil
5845
}
5946

Diff for: serverrpc/list.go

-13
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,41 @@
11
package serverrpc
22

33
import (
4-
"github.com/golang/glog"
54
"github.com/hyperhq/hyperd/types"
65
"golang.org/x/net/context"
76
)
87

98
// ContainerList implements GET /list?item=container
109
func (s *ServerRPC) ContainerList(ctx context.Context, req *types.ContainerListRequest) (*types.ContainerListResponse, error) {
11-
glog.V(3).Infof("ContainerList with request %s", req.String())
12-
1310
containerList, err := s.daemon.ListContainers(req.PodID, req.VmID)
1411
if err != nil {
15-
glog.Errorf("ContainerList failed %v with request %s", err, req.String())
1612
return nil, err
1713
}
1814

19-
glog.V(3).Infof("ContainerList done with request %s", req.String())
2015
return &types.ContainerListResponse{
2116
ContainerList: containerList,
2217
}, nil
2318
}
2419

2520
// PodList implements GET /list?item=pod
2621
func (s *ServerRPC) PodList(ctx context.Context, req *types.PodListRequest) (*types.PodListResponse, error) {
27-
glog.V(3).Infof("PodList with request %s", req.String())
28-
2922
podList, err := s.daemon.ListPods(req.PodID, req.VmID)
3023
if err != nil {
31-
glog.Errorf("PodList failed %v with request %s", err, req.String())
3224
return nil, err
3325
}
3426

35-
glog.V(3).Infof("PodList done with request %s", req.String())
3627
return &types.PodListResponse{
3728
PodList: podList,
3829
}, nil
3930
}
4031

4132
// VMList implements GET /list?item=vm
4233
func (s *ServerRPC) VMList(ctx context.Context, req *types.VMListRequest) (*types.VMListResponse, error) {
43-
glog.V(3).Infof("VMList with request %s", req.String())
44-
4534
vmList, err := s.daemon.ListVMs(req.PodID, req.VmID)
4635
if err != nil {
47-
glog.Errorf("VmList failed %v with request %s", err, req.String())
4836
return nil, err
4937
}
5038

51-
glog.V(3).Infof("VMList done with request %s", req.String())
5239
return &types.VMListResponse{
5340
VmList: vmList,
5441
}, nil

Diff for: serverrpc/logs.go

-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
)
1313

1414
func (s *ServerRPC) ContainerLogs(req *types.ContainerLogsRequest, stream types.PublicAPI_ContainerLogsServer) error {
15-
glog.V(3).Infof("ContainerLogs with request %s", req.String())
16-
1715
var since time.Time
1816
if req.Since != "" {
1917
s, n, err := timetypes.ParseTimestamps(req.Since, 0)
@@ -71,6 +69,5 @@ func (s *ServerRPC) ContainerLogs(req *types.ContainerLogsRequest, stream types.
7169
}
7270
}
7371

74-
glog.V(3).Infof("ContainerLogs done with request %s", req.String())
7572
return nil
7673
}

0 commit comments

Comments
 (0)