@@ -10,8 +10,8 @@ import (
1010 "time"
1111
1212 "github.com/containerd/log"
13- "github.com/docker/docker/api/types"
1413 "github.com/docker/docker/api/types/backend"
14+ containertypes "github.com/docker/docker/api/types/container"
1515 "github.com/docker/docker/api/types/events"
1616 "github.com/docker/docker/api/types/strslice"
1717 "github.com/docker/docker/container"
@@ -55,7 +55,7 @@ const (
5555type probe interface {
5656 // Perform one run of the check. Returns the exit code and an optional
5757 // short diagnostic string.
58- run (context.Context , * Daemon , * container.Container ) (* types .HealthcheckResult , error )
58+ run (context.Context , * Daemon , * container.Container ) (* containertypes .HealthcheckResult , error )
5959}
6060
6161// cmdProbe implements the "CMD" probe type.
@@ -66,7 +66,7 @@ type cmdProbe struct {
6666
6767// exec the healthcheck command in the container.
6868// Returns the exit code and probe output (if any)
69- func (p * cmdProbe ) run (ctx context.Context , d * Daemon , cntr * container.Container ) (* types .HealthcheckResult , error ) {
69+ func (p * cmdProbe ) run (ctx context.Context , d * Daemon , cntr * container.Container ) (* containertypes .HealthcheckResult , error ) {
7070 startTime := time .Now ()
7171 cmdSlice := strslice .StrSlice (cntr .Config .Healthcheck .Test )[1 :]
7272 if p .shell {
@@ -145,7 +145,7 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container
145145 } else {
146146 msg = fmt .Sprintf ("Health check exceeded timeout (%v)" , probeTimeout )
147147 }
148- return & types .HealthcheckResult {
148+ return & containertypes .HealthcheckResult {
149149 ExitCode : - 1 ,
150150 Output : msg ,
151151 End : time .Now (),
@@ -173,15 +173,15 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container
173173 }
174174 // Note: Go's json package will handle invalid UTF-8 for us
175175 out := output .String ()
176- return & types .HealthcheckResult {
176+ return & containertypes .HealthcheckResult {
177177 End : time .Now (),
178178 ExitCode : exitCode ,
179179 Output : out ,
180180 }, nil
181181}
182182
183183// Update the container's Status.Health struct based on the latest probe's result.
184- func handleProbeResult (d * Daemon , c * container.Container , result * types .HealthcheckResult , done chan struct {}) {
184+ func handleProbeResult (d * Daemon , c * container.Container , result * containertypes .HealthcheckResult , done chan struct {}) {
185185 c .Lock ()
186186 defer c .Unlock ()
187187
@@ -208,14 +208,14 @@ func handleProbeResult(d *Daemon, c *container.Container, result *types.Healthch
208208
209209 if result .ExitCode == exitStatusHealthy {
210210 h .FailingStreak = 0
211- h .SetStatus (types .Healthy )
211+ h .SetStatus (containertypes .Healthy )
212212 } else { // Failure (including invalid exit code)
213213 shouldIncrementStreak := true
214214
215215 // If the container is starting (i.e. we never had a successful health check)
216216 // then we check if we are within the start period of the container in which
217217 // case we do not increment the failure streak.
218- if h .Status () == types .Starting {
218+ if h .Status () == containertypes .Starting {
219219 startPeriod := timeoutWithDefault (c .Config .Healthcheck .StartPeriod , defaultStartPeriod )
220220 timeSinceStart := result .Start .Sub (c .State .StartedAt )
221221
@@ -229,7 +229,7 @@ func handleProbeResult(d *Daemon, c *container.Container, result *types.Healthch
229229 h .FailingStreak ++
230230
231231 if h .FailingStreak >= retries {
232- h .SetStatus (types .Unhealthy )
232+ h .SetStatus (containertypes .Unhealthy )
233233 }
234234 }
235235 // Else we're starting or healthy. Stay in that state.
@@ -270,7 +270,7 @@ func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe)
270270 status := c .Health .Health .Status
271271 c .Unlock ()
272272
273- if status == types .Starting {
273+ if status == containertypes .Starting {
274274 return startInterval
275275 }
276276 return probeInterval
@@ -288,14 +288,14 @@ func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe)
288288 log .G (context .TODO ()).Debugf ("Running health check for container %s ..." , c .ID )
289289 startTime := time .Now ()
290290 ctx , cancelProbe := context .WithCancel (context .Background ())
291- results := make (chan * types .HealthcheckResult , 1 )
291+ results := make (chan * containertypes .HealthcheckResult , 1 )
292292 go func () {
293293 healthChecksCounter .Inc ()
294294 result , err := probe .run (ctx , d , c )
295295 if err != nil {
296296 healthChecksFailedCounter .Inc ()
297297 log .G (ctx ).Warnf ("Health check for container %s error: %v" , c .ID , err )
298- results <- & types .HealthcheckResult {
298+ results <- & containertypes .HealthcheckResult {
299299 ExitCode : - 1 ,
300300 Output : err .Error (),
301301 Start : startTime ,
@@ -379,11 +379,11 @@ func (daemon *Daemon) initHealthMonitor(c *container.Container) {
379379 daemon .stopHealthchecks (c )
380380
381381 if h := c .State .Health ; h != nil {
382- h .SetStatus (types .Starting )
382+ h .SetStatus (containertypes .Starting )
383383 h .FailingStreak = 0
384384 } else {
385385 h := & container.Health {}
386- h .SetStatus (types .Starting )
386+ h .SetStatus (containertypes .Starting )
387387 c .State .Health = h
388388 }
389389
0 commit comments