This takes the final removal for exec commands in two steps. The first
GC tick will mark the exec commands for removal and then the second tick
will remove the config from the daemon.
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
... | ... |
@@ -28,6 +28,7 @@ type execConfig struct { |
28 | 28 |
OpenStderr bool |
29 | 29 |
OpenStdout bool |
30 | 30 |
Container *Container |
31 |
+ canRemove bool |
|
31 | 32 |
} |
32 | 33 |
|
33 | 34 |
type execStore struct { |
... | ... |
@@ -256,12 +257,15 @@ func (d *Daemon) execCommandGC() { |
256 | 256 |
var ( |
257 | 257 |
cleaned int |
258 | 258 |
liveExecCommands = d.containerExecIds() |
259 |
- ids = d.execCommands.List() |
|
260 | 259 |
) |
261 |
- for _, id := range ids { |
|
262 |
- if _, exists := liveExecCommands[id]; !exists { |
|
260 |
+ for id, config := range d.execCommands.s { |
|
261 |
+ if config.canRemove { |
|
263 | 262 |
cleaned++ |
264 | 263 |
d.execCommands.Delete(id) |
264 |
+ } else { |
|
265 |
+ if _, exists := liveExecCommands[id]; !exists { |
|
266 |
+ config.canRemove = true |
|
267 |
+ } |
|
265 | 268 |
} |
266 | 269 |
} |
267 | 270 |
logrus.Debugf("clean %d unused exec commands", cleaned) |