!77 kata-containers: fix shimv2 exit problem

Merge pull request !77 from holyfei/openEuler-20.03-LTS-SP3
This commit is contained in:
openeuler-ci-bot 2021-12-17 09:17:00 +00:00 committed by Gitee
commit 56fe247c31
3 changed files with 7 additions and 80 deletions

View File

@ -1,78 +0,0 @@
From 3ac1232a2e3fbfc0465473e5d81cde41847c4252 Mon Sep 17 00:00:00 2001
From: jiangpengfei <jiangpengfei9@huawei.com>
Date: Wed, 19 Aug 2020 11:47:37 +0800
Subject: [PATCH 11/16] agent: fix agent reap agent process blocked problem
reason: add container waitProcess() timeout when
container process status is D/T.
Signed-off-by: jiangpengfei <jiangpengfei9@huawei.com>
---
grpc.go | 43 +++++++++++++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/grpc.go b/grpc.go
index de2cae7..3dd088e 100644
--- a/grpc.go
+++ b/grpc.go
@@ -49,6 +49,11 @@ const (
libcontainerPath = "/run/libcontainer"
)
+// keep waitProcessTimeout value same as value in kata-runtime wait WaitProcessRequest response
+const (
+ waitProcessTimeOut = 10
+)
+
var (
sysfsCPUOnlinePath = "/sys/devices/system/cpu"
sysfsMemOnlinePath = "/sys/devices/system/memory"
@@ -996,17 +1001,35 @@ func (a *agentGRPC) WaitProcess(ctx context.Context, req *pb.WaitProcessRequest)
ctr.deleteProcess(proc.id)
})
- // Using helper function wait() to deal with the subreaper.
- libContProcess := (*reaperLibcontainerProcess)(&(proc.process))
- exitCode, err := a.sandbox.subreaper.wait(proc.exitCodeCh, libContProcess)
- if err != nil {
- return &pb.WaitProcessResponse{}, err
+ done := make(chan error)
+ var exitCode int = 0
+ go func() {
+ // Using helper function wait() to deal with the subreaper.
+ libContProcess := (*reaperLibcontainerProcess)(&(proc.process))
+ var err error
+ exitCode, err = a.sandbox.subreaper.wait(proc.exitCodeCh, libContProcess)
+ if err != nil {
+ done <- err
+ close(done)
+ return
+ }
+ // refill the exitCodeCh with the exitcode which can be read out
+ // by another WaitProcess(). Since this channel isn't be closed,
+ // here the refill will always success and it will be free by GC
+ // once the process exits.
+ proc.exitCodeCh <- exitCode
+
+ close(done)
+ }()
+
+ select {
+ case err := <-done:
+ if err != nil {
+ return &pb.WaitProcessResponse{}, err
+ }
+ case <-time.After(time.Duration(waitProcessTimeOut) * time.Second):
+ return &pb.WaitProcessResponse{}, grpcStatus.Errorf(codes.DeadlineExceeded, "agent wait reap container process timeout reached after %ds", waitProcessTimeOut)
}
- //refill the exitCodeCh with the exitcode which can be read out
- //by another WaitProcess(). Since this channel isn't be closed,
- //here the refill will always success and it will be free by GC
- //once the process exits.
- proc.exitCodeCh <- exitCode
return &pb.WaitProcessResponse{
Status: int32(exitCode),
--
2.14.3 (Apple Git-98)

View File

@ -8,7 +8,6 @@
0008-agent-support-get-root-bus-path-dynamically.patch
0009-storage-add-pkg-storage-for-mount.patch
0010-storage-mount-nfs-and-gpath-in-agent.patch
0011-agent-fix-agent-reap-agent-process-blocked-problem.patch
0012-network-support-set-dns-without-nameserver.patch
0013-agent-support-setting-multi-queues-of-interface.patch
0014-agent-fix-init-hugepages-failed-problem.patch

View File

@ -2,7 +2,7 @@
%global debug_package %{nil}
%define VERSION v1.11.1
%define RELEASE 11
%define RELEASE 12
Name: kata-containers
Version: %{VERSION}
@ -92,6 +92,12 @@ install -p -m 640 -D ./runtime/cli/config/configuration-qemu.toml %{buildroot}/u
%changelog
* Fri Dec 17 2021 yangfeiyu <yangfeiyu2@huawei.com> - 1.11.1-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix shimv2 exit problem
* Sat Nov 27 2021 yangfeiyu <yangfeiyu2@huawei.com> - 1.11.1-11
- Type:enhancement
- ID:NA