-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: fix exec stuck when exec get error #1605
Conversation
Hi, @Letty5411 , I want you to help look at a test
As for fix exec hang, I ignore the error do not worry about this, I have fix this. |
Codecov Report
@@ Coverage Diff @@
## master #1605 +/- ##
=========================================
- Coverage 41.97% 40.78% -1.2%
=========================================
Files 270 270
Lines 17609 18100 +491
=========================================
- Hits 7392 7382 -10
- Misses 9307 9806 +499
- Partials 910 912 +2
|
daemon/mgr/container_exec.go
Outdated
|
||
"github.com/alibaba/pouch/apis/types" | ||
"github.com/alibaba/pouch/ctrd" | ||
"github.com/alibaba/pouch/pkg/errtypes" | ||
"github.com/alibaba/pouch/pkg/randomid" | ||
"github.com/docker/docker/pkg/stdcopy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move the package into next group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh!
case err := <-stdoutDone: | ||
if err != nil { | ||
logrus.Debugf("receive stdout error: %s", err) | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the code goes into this part, the following code will go into the end?
go func() {
if stdin {
io.Copy(conn, os.Stdin)
}
close(stdinDone)
}()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is nit comment. If there exists goroutine leak, the cli will die to make the goroutine exit....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe depend on when golang schedule the goroutine if stdin is flase
, if stdin if true, it must became a leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But the cli will return and exit so that the leak problem will be solved. This part is LGTM right now.
@YaoZengzeng , Could you help to see if the patch will infect CRI part. |
exitCode := 126 | ||
execConfig.ExitCode = int64(exitCode) | ||
} | ||
mgr.ExecProcesses.Put(execid, execConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think mgr.ExecProcesses.Put(execid, execConfig)
is unnecessary, since it has added in CreateExec
, WDYT, @fuweid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allencloud , @HusterWan , does mgr.ExecProcesses.Put(execid, execConfig)
can be removed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ace-Tang I do not think so, we will use exec/EXEC_ID/json
to judge the exec result, so we should update the execConfig
when exec done
defer func() { | ||
if err != nil { | ||
var stdout io.Writer = eio.Stdout | ||
if !execConfig.Tty && !eio.MuxDisabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the judgement, @fuweid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ExecProcesses
is useful and please add it back?
cli/exec.go
Outdated
"os" | ||
"sync" | ||
|
||
"github.com/alibaba/pouch/apis/types" | ||
"github.com/docker/docker/pkg/stdcopy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you mind to split it into two parts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think this part is not fixed this time.
Updated as the comment, @HusterWan @fuweid |
@@ -55,8 +56,13 @@ func (s *Server) startContainerExec(ctx context.Context, rw http.ResponseWriter, | |||
name := mux.Vars(req)["name"] | |||
_, upgrade := req.Header["Upgrade"] | |||
|
|||
if err := s.ContainerMgr.CheckExecExist(ctx, name); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we should keep consistent that object existence checking should be located in the manager layer rather than bridge layer?
So maybe we should encapsulate this checking into the function StartExec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if check in StartExec
, it too late. StartExec
will not return error, since hikacked connection not take error back, we only write error message into connect, then api will get the error message, if check is in StartExec, we will never get error.
apis/server/router.go
Outdated
@@ -186,6 +186,7 @@ func filter(handler handler, s *Server) http.HandlerFunc { | |||
return | |||
} | |||
// Handle error if request handling fails. | |||
logrus.Errorf("Handler for %s %s, client %s returen error: %s", req.Method, req.URL.RequestURI(), clientInfo, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/returen/returned
ping @Ace-Tang |
when daemon deal with exec process get error, process will get stuck, since http connection has been hijacked, it won't finish and return with error message. Fix it by write error message into hijacked connection, close io when process get error. fixes: #1151 Signed-off-by: Ace-Tang <aceapril@126.com>
LGTM |
when daemon deal with exec process get error, process will get stuck,
since http connection has been hijacked, it won't finish and return
with error message. Fix it by write error message into hijacked
connection, close io when process get error.
fixes: #1151
Signed-off-by: Ace-Tang aceapril@126.com
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
fixes: #1151
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews