Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -23,6 +23,9 @@ type container struct {
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
func (ctr *container) clean() error {
|
| 26 |
+ if os.Getenv("LIBCONTAINERD_NOCLEAN") == "1" {
|
|
| 27 |
+ return nil |
|
| 28 |
+ } |
|
| 26 | 29 |
if _, err := os.Lstat(ctr.dir); err != nil {
|
| 27 | 30 |
if os.IsNotExist(err) {
|
| 28 | 31 |
return nil |
| ... | ... |
@@ -141,9 +144,12 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
|
| 141 | 141 |
ctr.client.deleteContainer(e.Id) |
| 142 | 142 |
go func() {
|
| 143 | 143 |
err := <-wait |
| 144 |
+ ctr.client.lock(ctr.containerID) |
|
| 145 |
+ defer ctr.client.unlock(ctr.containerID) |
|
| 144 | 146 |
ctr.restarting = false |
| 145 | 147 |
if err != nil {
|
| 146 | 148 |
st.State = StateExit |
| 149 |
+ ctr.clean() |
|
| 147 | 150 |
ctr.client.q.append(e.Id, func() {
|
| 148 | 151 |
if err := ctr.client.backend.StateChanged(e.Id, st); err != nil {
|
| 149 | 152 |
logrus.Error(err) |
| ... | ... |
@@ -163,9 +169,7 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
|
| 163 | 163 |
// We need to do so here in case the Message Handler decides to restart it. |
| 164 | 164 |
switch st.State {
|
| 165 | 165 |
case StateExit: |
| 166 |
- if os.Getenv("LIBCONTAINERD_NOCLEAN") != "1" {
|
|
| 167 |
- ctr.clean() |
|
| 168 |
- } |
|
| 166 |
+ ctr.clean() |
|
| 169 | 167 |
ctr.client.deleteContainer(e.Id) |
| 170 | 168 |
case StateExitProcess: |
| 171 | 169 |
ctr.cleanProcess(st.ProcessID) |