@@ -349,6 +349,20 @@ func (ht *hcsTask) KillExec(ctx context.Context, eid string, signal uint32, all
349349 return errors .Wrap (errdefs .ErrFailedPrecondition , "cannot signal init exec with un-exited additional exec's" )
350350 }
351351 }
352+ if signal == 0x9 && eid == "" && ht .ownsHost && ht .host != nil {
353+ go func () {
354+ // The caller has issued a SIGKILL to the init process that owns the
355+ // host.
356+ //
357+ // To mitigate failures that can cause the HCS to never deliver the
358+ // exit notification give everything 30 seconds and terminate the
359+ // UVM to force all exits.
360+ time .Sleep (30 * time .Second )
361+ // Safe to call multiple times if called previously on successful
362+ // shutdown.
363+ ht .host .Close ()
364+ }()
365+ }
352366 eg .Go (func () error {
353367 return e .Kill (ctx , signal )
354368 })
@@ -506,7 +520,7 @@ func (ht *hcsTask) close() {
506520 if ht .c != nil {
507521 // Do our best attempt to tear down the container.
508522 if err := ht .c .Shutdown (); err != nil {
509- if hcs .IsAlreadyClosed (err ) || hcs .IsAlreadyStopped (err ) {
523+ if hcs .IsAlreadyClosed (err ) || hcs .IsNotExist ( err ) || hcs . IsAlreadyStopped (err ) {
510524 // This is the state we want. Do nothing.
511525 } else if ! hcs .IsPending (err ) {
512526 logrus .WithFields (logrus.Fields {
@@ -523,7 +537,7 @@ func (ht *hcsTask) close() {
523537 }
524538 }
525539 if err := ht .c .Terminate (); err != nil {
526- if hcs .IsAlreadyClosed (err ) || hcs .IsAlreadyStopped (err ) {
540+ if hcs .IsAlreadyClosed (err ) || hcs .IsNotExist ( err ) || hcs . IsAlreadyStopped (err ) {
527541 // This is the state we want. Do nothing.
528542 } else if ! hcs .IsPending (err ) {
529543 logrus .WithFields (logrus.Fields {
0 commit comments