78 lines
3.1 KiB
Diff
78 lines
3.1 KiB
Diff
From 7b9e8a793fa6c0ec67effac0bc53d55c275e13be Mon Sep 17 00:00:00 2001
|
|
From: jingrui <jingrui@huawei.com>
|
|
Date: Thu, 25 Jul 2019 19:29:50 +0800
|
|
Subject: [PATCH] containerd: run state with timeout 10s
|
|
|
|
Change-Id: Idf55f750c2e7c6a9268318f519f1c8bc1595e09e
|
|
Signed-off-by: jingrui <jingrui@huawei.com>
|
|
---
|
|
Makefile | 4 ++--
|
|
runtime/v1/linux/task.go | 3 ---
|
|
services/tasks/local.go | 11 +++++++++++
|
|
3 files changed, 13 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
index 5de5cf75..9e7f3ae3 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -81,8 +81,8 @@ GO_TAGS=$(if $(BUILDTAGS),-tags "$(BUILDTAGS)",)
|
|
BEP_DIR=/tmp/containerd-build-bep
|
|
BEP_FLAGS=-tmpdir=/tmp/containerd-build-bep
|
|
|
|
-GO_LDFLAGS=-ldflags '-s -w -buildid=IdByIsula -extldflags=-zrelro -extldflags=-znow $(BEP_FLAGS) -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) $(EXTRA_LDFLAGS)'
|
|
-SHIM_GO_LDFLAGS=-ldflags '-s -w -buildid=IdByIsula $(BEP_FLAGS) -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -extldflags "-static"'
|
|
+GO_LDFLAGS=-ldflags ' -buildid=IdByIsula -extldflags=-zrelro -extldflags=-znow $(BEP_FLAGS) -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) $(EXTRA_LDFLAGS)'
|
|
+SHIM_GO_LDFLAGS=-ldflags ' -buildid=IdByIsula $(BEP_FLAGS) -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -extldflags "-static"'
|
|
|
|
#Replaces ":" (*nix), ";" (windows) with newline for easy parsing
|
|
GOPATHS=$(shell echo ${GOPATH} | tr ":" "\n" | tr ";" "\n")
|
|
diff --git a/runtime/v1/linux/task.go b/runtime/v1/linux/task.go
|
|
index b692ae78..d2bbb764 100644
|
|
--- a/runtime/v1/linux/task.go
|
|
+++ b/runtime/v1/linux/task.go
|
|
@@ -92,9 +92,6 @@ func (t *Task) delete(ctx context.Context, force bool, pid uint32) (*runtime.Exi
|
|
rsp, err := t.shim.Delete(ctx, empty)
|
|
if err != nil {
|
|
log.G(ctx).WithError(err).Error("failed to delete container, force=%t", force)
|
|
- if !force {
|
|
- return nil, errdefs.FromGRPC(err)
|
|
- }
|
|
}
|
|
t.tasks.Delete(ctx, t.id)
|
|
if err := t.shim.KillShim(ctx); err != nil {
|
|
diff --git a/services/tasks/local.go b/services/tasks/local.go
|
|
index ce9ee59d..990e8411 100644
|
|
--- a/services/tasks/local.go
|
|
+++ b/services/tasks/local.go
|
|
@@ -47,6 +47,7 @@ import (
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
"github.com/pkg/errors"
|
|
+ "github.com/sirupsen/logrus"
|
|
bolt "go.etcd.io/bbolt"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/codes"
|
|
@@ -185,9 +186,19 @@ func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.
|
|
if err := l.monitor.Monitor(c); err != nil {
|
|
return nil, errors.Wrap(err, "monitor task")
|
|
}
|
|
+
|
|
+ ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
|
|
+ defer cancel()
|
|
+
|
|
state, err := c.State(ctx)
|
|
if err != nil {
|
|
log.G(ctx).Error(err)
|
|
+ go func() {
|
|
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
+ defer cancel()
|
|
+ _, err := c.Delete(ctx)
|
|
+ logrus.Errorf("failed get pid, delete force error=%v", err)
|
|
+ }()
|
|
}
|
|
return &api.CreateTaskResponse{
|
|
ContainerID: r.ContainerID,
|
|
--
|
|
2.17.1
|
|
|