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>
| ... | ... |
@@ -118,6 +118,8 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c |
| 118 | 118 |
defer close(messageChan) |
| 119 | 119 |
|
| 120 | 120 |
lg.Debug("begin logs")
|
| 121 |
+ defer lg.Debugf("end logs (%v)", ctx.Err())
|
|
| 122 |
+ |
|
| 121 | 123 |
for {
|
| 122 | 124 |
select {
|
| 123 | 125 |
// 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 |
| 132 | 132 |
} |
| 133 | 133 |
return |
| 134 | 134 |
case <-ctx.Done(): |
| 135 |
- lg.Debugf("logs: end stream, ctx is done: %v", ctx.Err())
|
|
| 136 | 135 |
return |
| 137 | 136 |
case msg, ok := <-logs.Msg: |
| 138 | 137 |
// there is some kind of pool or ring buffer in the logger that |
| 139 | 138 |
// produces these messages, and a possible future optimization |
| 140 | 139 |
// might be to use that pool and reuse message objects |
| 141 | 140 |
if !ok {
|
| 142 |
- lg.Debug("end logs")
|
|
| 143 | 141 |
return |
| 144 | 142 |
} |
| 145 | 143 |
m := msg.AsLogMessage() // just a pointer conversion, does not copy data |