Skip to content
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

feature: add pouch kill functionality #1485

Merged
merged 1 commit into from
Jun 14, 2018

Conversation

xiechengsheng
Copy link
Contributor

Signed-off-by: xiechengsheng XIE1995@whut.edu.cn

Ⅰ. Describe what this PR did

add pouch kill functionality

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

$ pouch ps
Name            ID       Status          Created          Image                                            Runtime
foo             c926cf   Up 5 seconds    6 seconds ago    registry.hub.docker.com/library/busybox:latest   runc
$ pouch kill foo
foo
$ pouch ps -a
Name            ID       Status                     Created          Image                                            Runtime
foo             c926cf   Exited (137) 9 seconds     25 seconds ago   registry.hub.docker.com/library/busybox:latest   runc

Ⅴ. Special notes for reviews

NONE

@codecov-io
Copy link

codecov-io commented Jun 7, 2018

Codecov Report

Merging #1485 into master will increase coverage by 0.02%.
The diff coverage is 47.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1485      +/-   ##
==========================================
+ Coverage   40.83%   40.85%   +0.02%     
==========================================
  Files         254      256       +2     
  Lines       16601    16714     +113     
==========================================
+ Hits         6779     6829      +50     
- Misses       8954     9007      +53     
- Partials      868      878      +10
Impacted Files Coverage Δ
cli/kill.go 0% <0%> (ø)
cli/main.go 0% <0%> (ø) ⬆️
apis/server/container_bridge.go 83.69% <100%> (+0.8%) ⬆️
client/container_kill.go 100% <100%> (ø)
apis/server/router.go 91.36% <100%> (+0.06%) ⬆️
ctrd/container.go 50.31% <55.81%> (+0.13%) ⬆️
daemon/mgr/container.go 49.06% <71.42%> (+0.25%) ⬆️
apis/server/utils.go 59.52% <0%> (-4.77%) ⬇️
... and 1 more

if sigStr := req.FormValue("signal"); sigStr != "" {
var err error
if sig, err = signal.ParseSignal(sigStr); err != nil {
return err
Copy link
Collaborator

@allencloud allencloud Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we need to return a status code of 400 bad request. WDYT? @xiechengsheng

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will add http 400 err here.

@@ -0,0 +1,20 @@
package client
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a mock test for this API?

}
ensureCloseReader(resp)

return err
Copy link
Collaborator

@allencloud allencloud Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, please explicitly return nilrather than return err.

}

if sig != 0 && !signal.ValidSignalForPlatform(syscall.Signal(sig)) {
return fmt.Errorf("signal: %d is not suppoerted", sig)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Errorf("signal %d is not supported", sig)

}

if !c.IsRunning() {
return fmt.Errorf("container: %s is not running, can not execute kill command", c.ID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove : in the error message.

@xiechengsheng xiechengsheng force-pushed the add-kill branch 3 times, most recently from 1d99e08 to b50b084 Compare June 13, 2018 15:11
@allencloud
Copy link
Collaborator

@xiechengsheng
CI fails with:

----------------------------------------------------------------------
FAIL: /go/src/github.com/alibaba/pouch/test/api_container_kill_test.go:92: APIContainerKillSuite.TestKillContainerWithInvalidSignal
/go/src/github.com/alibaba/pouch/test/api_container_kill_test.go:112:
    CheckRespStatus(c, resp, 204)
/go/src/github.com/alibaba/pouch/test/util_api.go:25:
    c.Assert(resp.StatusCode, check.Equals, status, check.Commentf("Error:%s", got.Message))
... obtained int = 500
... expected int = 204
... Error:process id fa1602b47d813085d88165f71bcf854abda35163c2d450000ac1156348ab4d6b: not found

default: "SIGKILL"
responses:
204:
description: "no error"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You add status code 400 in code, then here we need to add 400 as well in swagger. @xiechengsheng

Signed-off-by: xiechengsheng <XIE1995@whut.edu.cn>
@xiechengsheng
Copy link
Contributor Author

OK, I will fix this ASAP.

@allencloud
Copy link
Collaborator

LGTM, thank you very much for this excellent work. @xiechengsheng

@allencloud allencloud merged commit 6cf387a into AliyunContainerService:master Jun 14, 2018
@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Jun 14, 2018
@xiechengsheng
Copy link
Contributor Author

Wow, merged so quickly. 😄

@wangforthinker
Copy link
Contributor

Could we continue to push this feature? @fuweid @xiechengsheng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants