Skip to content

Commit 25c9e88

Browse files
authored
Merge pull request #3655 from kolyshkin/cpt-destroy-on-err
runc checkpoint: destroy only on success
2 parents c1045cc + 783f9ff commit 25c9e88

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

checkpoint.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ checkpointed.`,
6767
return err
6868
}
6969

70-
if !(options.LeaveRunning || options.PreDump) {
71-
// destroy container unless we tell CRIU to keep it
72-
defer destroy(container)
73-
}
7470
// these are the mandatory criu options for a container
7571
if err := setPageServer(context, options); err != nil {
7672
return err
@@ -81,7 +77,13 @@ checkpointed.`,
8177
if err := setEmptyNsMask(context, options); err != nil {
8278
return err
8379
}
84-
return container.Checkpoint(options)
80+
81+
err = container.Checkpoint(options)
82+
if err == nil && !(options.LeaveRunning || options.PreDump) {
83+
// Destroy the container unless we tell CRIU to keep it.
84+
destroy(container)
85+
}
86+
return err
8587
},
8688
}
8789

0 commit comments

Comments
 (0)