!343 [sync] PR-337: docker:try to reconnect when containerd grpc return unexpected EOF

From: @openeuler-sync-bot 
Reviewed-by: @zhangsong234 
Signed-off-by: @zhangsong234
This commit is contained in:
openeuler-ci-bot 2024-08-31 09:01:45 +00:00 committed by Gitee
commit 94af307878
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 67 additions and 3 deletions

View File

@ -1 +1 @@
18.09.0.340
18.09.0.341

View File

@ -1,6 +1,6 @@
Name: docker-engine
Version: 18.09.0
Release: 340
Release: 341
Epoch: 2
Summary: The open-source application container engine
Group: Tools/Docker
@ -227,6 +227,12 @@ fi
%endif
%changelog
* Sat Aug 31 2024 zhongjiawei<zhongjiawei1@huawei.com> - 2:18.09.0-341
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:try to reconnect when containerd grpc return unexpected EOF
* Fri Aug 02 2024 zhongjiawei<zhongjiawei1@huawei.com> - 2:18.09.0-340
- Type:bugfix
- CVE:NA

View File

@ -1 +1 @@
29173030b7e118013ed3e8a3773492c40928bb9c
678fb4d2b2fbf91642358d82e5680aec01a15d56

View File

@ -0,0 +1,57 @@
From 68ea83ecea0e38d084c0d15c9e99c0b4494b1f32 Mon Sep 17 00:00:00 2001
From: zhongjiawei <zhongjiawei1@huawei.com>
Date: Thu, 22 Aug 2024 20:22:43 +0800
Subject: [PATCH] docker: try to reconnect when containerd grpc return
unexpected EOF
---
.../engine/libcontainerd/client_daemon.go | 26 ++++++++++++++-----
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/components/engine/libcontainerd/client_daemon.go b/components/engine/libcontainerd/client_daemon.go
index 09ce6e1f5..14f420ed8 100755
--- a/components/engine/libcontainerd/client_daemon.go
+++ b/components/engine/libcontainerd/client_daemon.go
@@ -38,9 +38,12 @@ import (
"google.golang.org/grpc/status"
)
-// InitProcessName is the name given to the first process of a
-// container
-const InitProcessName = "init"
+const (
+ // InitProcessName is the name given to the first process of a container
+ InitProcessName = "init"
+ // RetryMax is the max num to connect containerd grpc
+ RetryMax = 10
+)
type container struct {
mu sync.Mutex
@@ -167,9 +170,20 @@ func (c *client) Restore(ctx context.Context, id string, attachStdio StdioCallba
err = wrapError(err)
}()
- ctr, err := c.client.LoadContainer(ctx, id)
- if err != nil {
- return false, -1, errors.WithStack(wrapError(err))
+ var ctr containerd.Container
+ var err1 error
+ for retry := 1; retry <= RetryMax; retry++ {
+ ctr, err1 = c.client.LoadContainer(ctx, id)
+ if err1 == nil {
+ break
+ } else if strings.Contains(err1.Error(), "unexpected EOF") {
+ time.Sleep(time.Millisecond * 100)
+ continue
+ }
+ return false, -1, errors.WithStack(wrapError(err1))
+ }
+ if err1 != nil {
+ return false, -1, errors.Wrap(wrapError(err1), "reconnect load contianer failed")
}
attachIO := func(fifos *cio.FIFOSet) (cio.IO, error) {
--
2.33.0

View File

@ -276,4 +276,5 @@ patch/0275-backport-fix-CVE-2024-32473.patch
patch/0276-docker-Ignore-SIGURG-on-Linux.patch
patch/0277-backport-fix-CVE-2024-41110.patch
patch/0278-docker-add-clone3-seccomp-whitelist-for-arm64.patch
patch/0279-docker-try-to-reconnect-when-containerd-grpc-return-.patch
#end