Skip to content
Permalink
Browse files
add timeout in case docker api call freezes
  • Loading branch information
bradrydzewski committed May 2, 2018
1 parent 9abc381 commit 86a359e35f4d5d79b5eff7ea651c8119d1bc19b1
Showing 1 changed file with 5 additions and 0 deletions.
@@ -11,6 +11,9 @@ import (
"docker.io/go-docker"
)

// default timeout for the collection cycle.
var timeout = time.Hour

// Collector defines a Docker container garbage collector.
type Collector interface {
Collect(context.Context) error
@@ -35,6 +38,8 @@ func New(client docker.APIClient, opt ...Option) Collector {
}

func (c *collector) Collect(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
c.collectContainers(ctx)
c.collectDanglingImages(ctx)
c.collectImages(ctx)

0 comments on commit 86a359e

Please sign in to comment.