Skip to content

Commit

Permalink
Fix panic on add_docker_metadata close (#21882) (#21889)
Browse files Browse the repository at this point in the history
If the processor was not properly initialized, for example because it
couldn't access the docker socket, then the watcher will be nil. Avoid
trying to stop the watcher in that case.

(cherry picked from commit 80b8f53)
  • Loading branch information
jsoriano authored Oct 16, 2020
1 parent 5498661 commit ef85f4d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ func (d *addDockerMetadata) Close() error {
if d.cgroups != nil {
d.cgroups.StopJanitor()
}
d.watcher.Stop()
// Watcher can be nil if processor failed on creation
if d.watcher != nil {
d.watcher.Stop()
}
err := processors.Close(d.sourceProcessor)
if err != nil {
return errors.Wrap(err, "closing source processor of add_docker_metadata")
Expand Down

0 comments on commit ef85f4d

Please sign in to comment.