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: enable managing more containers for some commands #1357

Merged
merged 1 commit into from
May 21, 2018

Conversation

xiechengsheng
Copy link
Contributor

enable managing more containers for some commands

Ⅰ. Describe what this PR did

Some commands just support managing one container/image, which is inconvenient for users to use. This pr enables managing one or more containers for some client commands and fixes little bugs in commands that support manage more than one container by now.

Ⅱ. Does this pull request fix one issue?

NONE.

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

$ pouch ps -a
Name            ID       Status                  Created        Image                                            Runtime
my_container2   0a83b7   Stopped (0) 3 seconds   1 minute ago   registry.hub.docker.com/library/busybox:latest   runc
my_container1   2aa41e   Stopped (0) 3 seconds   1 minute ago   registry.hub.docker.com/library/busybox:latest   runc
$ pouch start my_container1 my_container2
my_container1
my_container2
$ pouch ps 
Name            ID       Status         Created        Image                                            Runtime
my_container2   0a83b7   Up 8 seconds   1 minute ago   registry.hub.docker.com/library/busybox:latest   runc
my_container1   2aa41e   Up 9 seconds   1 minute ago   registry.hub.docker.com/library/busybox:latest   runc

More test codes are in test folder.

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented May 19, 2018

Codecov Report

Merging #1357 into master will decrease coverage by 0.07%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1357      +/-   ##
==========================================
- Coverage   17.34%   17.26%   -0.08%     
==========================================
  Files         189      189              
  Lines       11832    11886      +54     
==========================================
  Hits         2052     2052              
- Misses       9632     9686      +54     
  Partials      148      148
Impacted Files Coverage Δ
cli/rmi.go 0% <0%> (ø) ⬆️
cli/pause.go 0% <0%> (ø) ⬆️
cli/restart.go 0% <0%> (ø) ⬆️
cli/start.go 0% <0%> (ø) ⬆️
cli/rm.go 0% <0%> (ø) ⬆️
cli/unpause.go 0% <0%> (ø) ⬆️

@allencloud
Copy link
Collaborator

Could you help to review this? @ZouRui89 Thanks a lot.

cli/pause.go Outdated

"github.com/spf13/cobra"
)

// pauseDescription is used to describe pause command in detail and auto generate command doc.
var pauseDescription = "Pause a running container object in Pouchd. " +
var pauseDescription = "Pause one or more running containers object in Pouchd. " +
"when pausing, the container will pause its running but hold all the relevant resource." +
"This is useful when you wish to pause a container for a while and to restore the running status later." +
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the corresponding amount here. Thx.

cli/pause.go Outdated
@@ -22,10 +24,10 @@ type PauseCommand struct {
func (p *PauseCommand) Init(c *Cli) {
p.cli = c
p.cmd = &cobra.Command{
Use: "pause CONTAINER",
Short: "Pause a running container",
Use: "pause CONTAINER [CONTAINERS]",
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the value of Use to "pause CONTAINER [CONTAINER...]".

cli/rm.go Outdated

"github.com/alibaba/pouch/apis/types"

"github.com/spf13/cobra"
)

var rmDescription = `
Remove a container object in Pouchd.
Remove one or more container objects in Pouchd.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just delete the word object to keep consistency with other commands.

cli/start.go Outdated
@@ -29,9 +31,9 @@ func (s *StartCommand) Init(c *Cli) {
s.cli = c
s.cmd = &cobra.Command{
Use: "start [OPTIONS] CONTAINER",
Copy link
Contributor

Choose a reason for hiding this comment

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

"start [OPTIONS] CONTAINER [CONTAINER...]"

cli/start.go Outdated
if s.attach || s.stdin {
var wait chan struct{}
// We're going to attach to a container, we should make sure we only have one container.
Copy link
Contributor

Choose a reason for hiding this comment

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

Change it to "If We're going to attach to a container, we should make sure we only have one container."

if len(errs) > 0 {
return errors.New(strings.Join(errs, "\n"))
}

return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Change the value of Use to update amount in init function.

@ZouRui89
Copy link
Contributor

Please use "commit -sm" to sign off your commits.

@ZouRui89
Copy link
Contributor

Thx a lot for your work.
The cli part is quite import since it is directly demonstrated to our users.
Please change all the corresponding words in Init function, like the value of Use and any things else related to. Beside, the example part in all the cli files you revised should be also changed, since more than one containers can be operated within one command due to your excellent work. :)

@xiechengsheng
Copy link
Contributor Author

Thanks for your careful review~

res2 := command.PouchRun("create", "--name", name2, busyboxImage, "top")
defer DelContainerForceMultyTime(c, name2)
res2.Assert(c, icmd.Success)

Copy link
Contributor

@ZouRui89 ZouRui89 May 21, 2018

Choose a reason for hiding this comment

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

A for circulation can be used here to enhance the degree of simplicity. Just like the way you do in TestUnpauseMultiContainers.

res2 := command.PouchRun("run", "-d", "--cpu-share", "20", "--name", name2, busyboxImage)
defer DelContainerForceMultyTime(c, name2)
res2.Assert(c, icmd.Success)

Copy link
Contributor

Choose a reason for hiding this comment

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

The same circulation problem as below.

@xiechengsheng
Copy link
Contributor Author

OK, I'll fix this, thanks.

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

LGTM

@ZouRui89 ZouRui89 merged commit 1e75a11 into AliyunContainerService:master May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants