Sfoglia il codice sorgente

daemon.ContainerLogs: minor debug logging cleanup

This code has many return statements, for some of them the
"end logs" or "end stream" message was not printed, giving
the impression that this "for" loop never ended.

Make sure that "begin logs" is to be followed by "end logs".

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Kir Kolyshkin 7 anni fa
parent
commit
2e4c2a6bf9
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      daemon/logs.go

+ 2 - 2
daemon/logs.go

@@ -118,6 +118,8 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c
 		defer close(messageChan)
 		defer close(messageChan)
 
 
 		lg.Debug("begin logs")
 		lg.Debug("begin logs")
+		defer lg.Debugf("end logs (%v)", ctx.Err())
+
 		for {
 		for {
 			select {
 			select {
 			// i do not believe as the system is currently designed any error
 			// i do not believe as the system is currently designed any error
@@ -132,14 +134,12 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c
 				}
 				}
 				return
 				return
 			case <-ctx.Done():
 			case <-ctx.Done():
-				lg.Debugf("logs: end stream, ctx is done: %v", ctx.Err())
 				return
 				return
 			case msg, ok := <-logs.Msg:
 			case msg, ok := <-logs.Msg:
 				// there is some kind of pool or ring buffer in the logger that
 				// there is some kind of pool or ring buffer in the logger that
 				// produces these messages, and a possible future optimization
 				// produces these messages, and a possible future optimization
 				// might be to use that pool and reuse message objects
 				// might be to use that pool and reuse message objects
 				if !ok {
 				if !ok {
-					lg.Debug("end logs")
 					return
 					return
 				}
 				}
 				m := msg.AsLogMessage() // just a pointer conversion, does not copy data
 				m := msg.AsLogMessage() // just a pointer conversion, does not copy data