Skip to content

Commit 9d55853

Browse files
yacovmmastersingh24
authored andcommitted
[FAB-5633] Add logging to deliverclient/client.go
The deliveryservice/client.go stores retry logic that plays a role when the ordering service node is unreachable or malfunctioning. It lacks logging, and thus makes it hard to analyze postmortem and live situations. Change-Id: I7f3a3d52c5fc67bed400f0007aebdb5e61419ec9 Signed-off-by: yacovm <[email protected]> (cherry picked from commit e1f7c50) Signed-off-by: Gari Singh <[email protected]>
1 parent a3f5cb4 commit 9d55853

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/deliverservice/client.go

+11
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ func (bc *broadcastClient) try(action func() (interface{}, error)) (interface{},
9898
if err != nil {
9999
backoffDuration, retry = bc.shouldRetry(attempt, time.Since(start))
100100
if !retry {
101+
logger.Warning("Got error:", err, "at", attempt, "attempt. Ceasing to retry")
101102
break
102103
}
104+
logger.Warning("Got error:", err, ",at", attempt, "attempt. Retrying in", backoffDuration)
103105
bc.sleep(backoffDuration)
104106
continue
105107
}
@@ -135,11 +137,13 @@ func (bc *broadcastClient) sleep(duration time.Duration) {
135137

136138
func (bc *broadcastClient) connect() error {
137139
conn, endpoint, err := bc.prod.NewConnection()
140+
logger.Debug("Connected to", endpoint)
138141
if err != nil {
139142
logger.Error("Failed obtaining connection:", err)
140143
return err
141144
}
142145
ctx, cf := context.WithCancel(context.Background())
146+
logger.Debug("Establishing gRPC stream with", endpoint, "...")
143147
abc, err := bc.createClient(conn).Deliver(ctx)
144148
if err != nil {
145149
logger.Error("Connection to ", endpoint, "established but was unable to create gRPC stream:", err)
@@ -150,13 +154,16 @@ func (bc *broadcastClient) connect() error {
150154
if err == nil {
151155
return nil
152156
}
157+
logger.Warning("Failed running post-connection procedures:", err)
153158
// If we reached here, lets make sure connection is closed
154159
// and nullified before we return
155160
bc.Disconnect()
156161
return err
157162
}
158163

159164
func (bc *broadcastClient) afterConnect(conn *grpc.ClientConn, abc orderer.AtomicBroadcast_DeliverClient, cf context.CancelFunc) error {
165+
logger.Debug("Entering")
166+
defer logger.Debug("Exiting")
160167
bc.Lock()
161168
bc.conn = &connection{ClientConn: conn, cancel: cf}
162169
bc.BlocksDeliverer = abc
@@ -194,6 +201,8 @@ func (bc *broadcastClient) shouldStop() bool {
194201

195202
// Close makes the client close its connection and shut down
196203
func (bc *broadcastClient) Close() {
204+
logger.Debug("Entering")
205+
defer logger.Debug("Exiting")
197206
bc.Lock()
198207
defer bc.Unlock()
199208
if bc.shouldStop() {
@@ -209,6 +218,8 @@ func (bc *broadcastClient) Close() {
209218

210219
// Disconnect makes the client close the existing connection
211220
func (bc *broadcastClient) Disconnect() {
221+
logger.Debug("Entering")
222+
defer logger.Debug("Exiting")
212223
bc.Lock()
213224
defer bc.Unlock()
214225
if bc.conn == nil {

0 commit comments

Comments
 (0)