From d055603a252ab9cf6b36b5369045ebf4a384c5b8 Mon Sep 17 00:00:00 2001
From: liruilin4 <liruilin4@huawei.com>
Date: Mon, 9 Jul 2018 12:02:33 +0800
Subject: [PATCH] runc: reduce max number of retries to 10

[Changelog]:when killing containers in D state, now runc will do
100 retries, which leads that containerd blocks for 10 seconds.
[Author]:Ruilin Li

Change-Id: I1e08ef23ad065f5e3b88506726530187d2ccc797
---
 delete.go | 4 ++--
 init.go   | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/delete.go b/delete.go
index 746b0df..799c2a7 100644
--- a/delete.go
+++ b/delete.go
@@ -14,8 +14,8 @@ import (
 )
 
 func killContainer(container libcontainer.Container) error {
-	_ = container.Signal(unix.SIGKILL, false)
-	for i := 0; i < 100; i++ {
+	container.Signal(unix.SIGKILL, false)
+	for i := 0; i < 10; i++ {
 		time.Sleep(100 * time.Millisecond)
 		if err := container.Signal(unix.Signal(0), false); err != nil {
 			destroy(container)
diff --git a/init.go b/init.go
index bddc237..a0520b5 100644
--- a/init.go
+++ b/init.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+	"fmt"
 	"os"
 	"runtime"
 	"strconv"
@@ -34,6 +35,7 @@ func init() {
 
 		factory, _ := libcontainer.New("")
 		if err := factory.StartInitialization(); err != nil {
+			fmt.Fprintf(os.Stderr, "libcontainer: container start initialization failed: %s", err)
 			// as the error is sent back to the parent there is no need to log
 			// or write it to stderr because the parent process will handle this
 			os.Exit(1)
-- 
2.33.0

