Signed-off-by: allencloud <allen.sun@daocloud.io>
allencloud authored on 2016/09/28 15:00:46... | ... |
@@ -94,7 +94,7 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, container *container.Cont |
94 | 94 |
return nil, err |
95 | 95 |
} |
96 | 96 |
if info.ExitCode == nil { |
97 |
- return nil, fmt.Errorf("Healthcheck has no exit code!") |
|
97 |
+ return nil, fmt.Errorf("Healthcheck for container %s has no exit code!", container.ID) |
|
98 | 98 |
} |
99 | 99 |
// Note: Go's json package will handle invalid UTF-8 for us |
100 | 100 |
out := output.String() |
... | ... |
@@ -149,17 +149,17 @@ func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe) |
149 | 149 |
for { |
150 | 150 |
select { |
151 | 151 |
case <-stop: |
152 |
- logrus.Debug("Stop healthcheck monitoring (received while idle)") |
|
152 |
+ logrus.Debugf("Stop healthcheck monitoring for container %s (received while idle)", c.ID) |
|
153 | 153 |
return |
154 | 154 |
case <-time.After(probeInterval): |
155 |
- logrus.Debug("Running health check...") |
|
155 |
+ logrus.Debugf("Running health check for container %s ...", c.ID) |
|
156 | 156 |
startTime := time.Now() |
157 | 157 |
ctx, cancelProbe := context.WithTimeout(context.Background(), probeTimeout) |
158 | 158 |
results := make(chan *types.HealthcheckResult) |
159 | 159 |
go func() { |
160 | 160 |
result, err := probe.run(ctx, d, c) |
161 | 161 |
if err != nil { |
162 |
- logrus.Warnf("Health check error: %v", err) |
|
162 |
+ logrus.Warnf("Health check for container %s error: %v", c.ID, err) |
|
163 | 163 |
results <- &types.HealthcheckResult{ |
164 | 164 |
ExitCode: -1, |
165 | 165 |
Output: err.Error(), |
... | ... |
@@ -168,14 +168,14 @@ func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe) |
168 | 168 |
} |
169 | 169 |
} else { |
170 | 170 |
result.Start = startTime |
171 |
- logrus.Debugf("Health check done (exitCode=%d)", result.ExitCode) |
|
171 |
+ logrus.Debugf("Health check for container %s done (exitCode=%d)", c.ID, result.ExitCode) |
|
172 | 172 |
results <- result |
173 | 173 |
} |
174 | 174 |
close(results) |
175 | 175 |
}() |
176 | 176 |
select { |
177 | 177 |
case <-stop: |
178 |
- logrus.Debug("Stop healthcheck monitoring (received while probing)") |
|
178 |
+ logrus.Debugf("Stop healthcheck monitoring for container %s (received while probing)", c.ID) |
|
179 | 179 |
// Stop timeout and kill probe, but don't wait for probe to exit. |
180 | 180 |
cancelProbe() |
181 | 181 |
return |
... | ... |
@@ -184,7 +184,7 @@ func monitor(d *Daemon, c *container.Container, stop chan struct{}, probe probe) |
184 | 184 |
// Stop timeout |
185 | 185 |
cancelProbe() |
186 | 186 |
case <-ctx.Done(): |
187 |
- logrus.Debug("Health check taking too long") |
|
187 |
+ logrus.Debugf("Health check for container %s taking too long", c.ID) |
|
188 | 188 |
handleProbeResult(d, c, &types.HealthcheckResult{ |
189 | 189 |
ExitCode: -1, |
190 | 190 |
Output: fmt.Sprintf("Health check exceeded timeout (%v)", probeTimeout), |
... | ... |
@@ -213,7 +213,7 @@ func getProbe(c *container.Container) probe { |
213 | 213 |
case "CMD-SHELL": |
214 | 214 |
return &cmdProbe{shell: true} |
215 | 215 |
default: |
216 |
- logrus.Warnf("Unknown healthcheck type '%s' (expected 'CMD')", config.Test[0]) |
|
216 |
+ logrus.Warnf("Unknown healthcheck type '%s' (expected 'CMD') in container %s", config.Test[0], c.ID) |
|
217 | 217 |
return nil |
218 | 218 |
} |
219 | 219 |
} |
... | ... |
@@ -30,7 +30,7 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error { |
30 | 30 |
daemon.updateHealthMonitor(c) |
31 | 31 |
daemon.LogContainerEvent(c, "oom") |
32 | 32 |
case libcontainerd.StateExit: |
33 |
- // if containers AutoRemove flag is set, remove it after clean up |
|
33 |
+ // if container's AutoRemove flag is set, remove it after clean up |
|
34 | 34 |
if c.HostConfig.AutoRemove { |
35 | 35 |
defer func() { |
36 | 36 |
if err := daemon.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true, RemoveVolume: true}); err != nil { |