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

fixes: top options can't work #2252

Merged
merged 2 commits into from
Sep 19, 2018

Conversation

lifubang
Copy link
Contributor

@lifubang lifubang commented Sep 18, 2018

Signed-off-by: Lifubang lifubang@acmcoder.com

Ⅰ. Describe what this PR did

  1. When pouch top --help:
    top command is to display the running processes of a container.You can add options just like using Linux ps command.
    But when I run: pouch top redisps -aux
    It returns:
    Error: unknown shorthand flag: 'a' in -aux

  2. in https://github.com/alibaba/pouch/blob/master/docs/api/HTTP_API.md
    Display the running processes of a container
    POST /containers/{id}/top

But in https://github.com/alibaba/pouch/blob/master/client/container_top.go#L19
and https://github.com/alibaba/pouch/blob/master/apis/server/router.go#L57
The type is get.

And, in https://github.com/alibaba/pouch/blob/master/apis/server/container_bridge.go#L323
It uses req.Form.Get

Is post? or get?

Ⅱ. Does this pull request fix one issue?

NONE

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Yes, you already had test cases.

Ⅳ. Describe how to verify it

pouch top redisps -aux

Ⅴ. Special notes for reviews

Make pouch top options work
API use get method

@codecov
Copy link

codecov bot commented Sep 18, 2018

Codecov Report

❗ No coverage uploaded for pull request head (topoptions@c5f707f). Click here to learn what that means.
The diff coverage is n/a.

@pouchrobot pouchrobot added kind/bug This is bug report for project size/XS labels Sep 18, 2018
@pouchrobot
Copy link
Collaborator

We found this is your first time to contribute to Pouch, @lifubang
👏 We really appreciate it.
Just remind that you have read the contribution guide: https://github.com/alibaba/pouch/blob/master/CONTRIBUTING.md
If you didn't, you should do that first. If done, welcome again and please enjoy hacking! 🍻

@CLAassistant
Copy link

CLAassistant commented Sep 18, 2018

CLA assistant check
All committers have signed the CLA.

@allencloud
Copy link
Collaborator

Thanks a lot for your contribution. @lifubang
I think it is a GET method, like https://github.com/moby/moby/blob/master/api/swagger.yaml#L4957 . And we wish that API could be compatible with Moby's.

@lifubang
Copy link
Contributor Author

So, change to get?

@allencloud
Copy link
Collaborator

So, change to get?

I think we need to update the swagger.yml to make method to be get. Then @pouchrobot will automatically update the docs without interaction of humans. @lifubang

cli/top.go Outdated
@@ -31,7 +31,8 @@ func (top *TopCommand) Init(c *Cli) {
RunE: func(cmd *cobra.Command, args []string) error {
return top.runTop(args)
},
Example: topExamples(),
Example: topExamples(),
DisableFlagParsing: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot for this update. While for other commands like create, run and so on, we use flagSet.SetInterspersed(false)in

func (cc *CreateCommand) addFlags() {
	flagSet := cc.cmd.Flags()
	flagSet.SetInterspersed(false)

	c := addCommonFlags(flagSet)
	cc.container = c
}

How about making pouchd use the unified way of flagSet.SetInterspersed(false)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have finished.

@allencloud
Copy link
Collaborator

Do you use wechat or DingTalk? Please add me as a friend with account 15869045568. Thanks a lot. @lifubang

@lifubang
Copy link
Contributor Author

lifubang commented Sep 18, 2018

OK, wait a minute.

@lifubang lifubang force-pushed the topoptions branch 2 times, most recently from 1460498 to c5f707f Compare September 18, 2018 12:45
Signed-off-by: Lifubang <lifubang@acmcoder.com>
@allencloud
Copy link
Collaborator

Thanks again for the fix. While when I was checking the cli integration test, I found that there is no integration test for the args of pouch top command. Could you add one to lock down the functionality in test case? @lifubang

@pouchrobot pouchrobot added size/L and removed size/S labels Sep 19, 2018
@allencloud
Copy link
Collaborator

Thanks for the test cased added. I feel that we are almost there. Currently there is still some minor issue in code style:

#!/bin/bash -eo pipefail
make check
gometalinter
gometalinter --config .gometalinter.json ./...
test/api_container_top_test.go:1::warning: file is not goimported (goimports)
Makefile:148: recipe for target 'gometalinter' failed
make: *** [gometalinter] Error 1
Exited with code 2

Is the goimport failing or something esle? @lifubang

@lifubang lifubang force-pushed the topoptions branch 4 times, most recently from f3250bc to a26a864 Compare September 19, 2018 02:51
@AliyunContainerService AliyunContainerService deleted a comment from codecov bot Sep 19, 2018
@AliyunContainerService AliyunContainerService deleted a comment from codecov bot Sep 19, 2018
@AliyunContainerService AliyunContainerService deleted a comment from codecov bot Sep 19, 2018
@AliyunContainerService AliyunContainerService deleted a comment from codecov bot Sep 19, 2018
@AliyunContainerService AliyunContainerService deleted a comment from codecov bot Sep 19, 2018
@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #2252 into master will decrease coverage by 1.25%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2252      +/-   ##
==========================================
- Coverage   66.77%   65.52%   -1.26%     
==========================================
  Files         208      208              
  Lines       16923    16924       +1     
==========================================
- Hits        11301    11090     -211     
- Misses       4262     4508     +246     
+ Partials     1360     1326      -34
Flag Coverage Δ
#criv1alpha1test 32.74% <0%> (+0.07%) ⬆️
#criv1alpha2test 100% <ø> (+63.99%) ⬆️
#integrationtest 39.45% <100%> (-0.04%) ⬇️
#nodee2etest 33.56% <0%> (+0.12%) ⬆️
#unittest 23.76% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
apis/server/container_bridge.go 79.41% <100%> (+0.07%) ⬆️
cri/v1alpha2/server.go 42.4% <0%> (-36.81%) ⬇️
storage/quota/quota.go 12.02% <0%> (-36.07%) ⬇️
storage/quota/prjquota.go 12.58% <0%> (-12.59%) ⬇️
daemon/mgr/container_storage.go 50.93% <0%> (-8.18%) ⬇️
cri/v1alpha2/cri_wrapper.go 53.6% <0%> (-7.61%) ⬇️
apis/server/utils.go 61.9% <0%> (-4.77%) ⬇️
cri/stream/remotecommand/httpstream.go 43.52% <0%> (-3.11%) ⬇️
cri/v1alpha2/cri_utils.go 87.55% <0%> (-3.08%) ⬇️
cri/v1alpha2/cri.go 64.77% <0%> (-1.95%) ⬇️
... and 8 more

@allencloud
Copy link
Collaborator

I am afraid that CLI integration test fails:

----------------------------------------------------------------------
FAIL: /home/travis/gopath/src/github.com/alibaba/pouch/test/cli_top_test.go:72: PouchTopSuite.TestTopContainerWithOptions
/home/travis/gopath/src/github.com/alibaba/pouch/test/cli_top_test.go:84:
    c.Fatalf("unexpected output %s expected %s", out, expectString)
... Error: unexpected output USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMANDroot211170.40.012364?Ss04:060:00top expected UIDPID%CPU
----------------------------------------------------------------------

@lifubang PTAL.

Signed-off-by: Lifubang <lifubang@acmcoder.com>
@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Sep 19, 2018
@allencloud allencloud merged commit 6882ecf into AliyunContainerService:master Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants