Fix crash in Docker input plugin - Fixes #1195

Commit fixes crash in Docker input plugin caused by the fact that return value
might be nil when error occurs.

closes #1195
This commit is contained in:
Zdenek Styblik 2016-05-15 11:19:53 +00:00 committed by Cameron Sparr
parent 08ecfb8a67
commit 39df2635bd
2 changed files with 3 additions and 1 deletions

View File

@ -6,6 +6,8 @@
### Bugfixes ### Bugfixes
- [#1195](https://github.com/influxdata/telegraf/pull/1195): Docker panic on timeout. Thanks @zstyblik!
## v0.13 [2016-05-11] ## v0.13 [2016-05-11]
### Release Notes ### Release Notes

View File

@ -221,7 +221,7 @@ func (d *Docker) gatherContainer(
defer cancel() defer cancel()
r, err := d.client.ContainerStats(ctx, container.ID, false) r, err := d.client.ContainerStats(ctx, container.ID, false)
if err != nil { if err != nil {
log.Printf("Error getting docker stats: %s\n", err.Error()) return fmt.Errorf("Error getting docker stats: %s", err.Error())
} }
defer r.Close() defer r.Close()
dec := json.NewDecoder(r) dec := json.NewDecoder(r)