Signed-off-by: John Howard <jhoward@microsoft.com>
This ensures that any compute processes in HCS are cleanedup
during daemon restore. Note Windows cannot (currently) reconnect
to containers on restore.
(cherry picked from commit f59593cbd1c177fe2d5a1b1f00efe9987d25a526)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
| ... | ... |
@@ -552,8 +552,22 @@ func (clnt *client) Stats(containerID string) (*Stats, error) {
|
| 552 | 552 |
|
| 553 | 553 |
// Restore is the handler for restoring a container |
| 554 | 554 |
func (clnt *client) Restore(containerID string, _ StdioCallback, unusedOnWindows ...CreateOption) error {
|
| 555 |
- // TODO Windows: Implement this. For now, just tell the backend the container exited. |
|
| 556 | 555 |
logrus.Debugf("libcontainerd: Restore(%s)", containerID)
|
| 556 |
+ |
|
| 557 |
+ // TODO Windows: On RS1, a re-attach isn't possible. |
|
| 558 |
+ // However, there is a scenario in which there is an issue. |
|
| 559 |
+ // Consider a background container. The daemon dies unexpectedly. |
|
| 560 |
+ // HCS will still have the compute service alive and running. |
|
| 561 |
+ // For consistence, we call in to shoot it regardless if HCS knows about it |
|
| 562 |
+ // We explicitly just log a warning if the terminate fails. |
|
| 563 |
+ // Then we tell the backend the container exited. |
|
| 564 |
+ if hc, err := hcsshim.OpenContainer(containerID); err == nil {
|
|
| 565 |
+ if err := hc.Terminate(); err != nil {
|
|
| 566 |
+ if !hcsshim.IsPending(err) {
|
|
| 567 |
+ logrus.Warnf("libcontainerd: failed to terminate %s on restore - %q", containerID, err)
|
|
| 568 |
+ } |
|
| 569 |
+ } |
|
| 570 |
+ } |
|
| 557 | 571 |
return clnt.backend.StateChanged(containerID, StateInfo{
|
| 558 | 572 |
CommonStateInfo: CommonStateInfo{
|
| 559 | 573 |
State: StateExit, |