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

Add -a option to service/node ps #25983

Merged
merged 1 commit into from
Nov 7, 2016
Merged

Conversation

jhorwit2
Copy link
Contributor

@jhorwit2 jhorwit2 commented Aug 24, 2016

Reopened #25251 because of weird github issue.

closes #25180
closes #25196

- What I did

I added an -a and --all flag to both commands to show all tasks.

- How I did it

Added a default filter to the CLI command when -a is false.

- How to verify it

Look at tests.

Run docker service ps & docker node ps on various nodes to ensure that only tasks are shown that are running or will be running w/o the -a flag. Also, make sure that --filter desired-state=<state> works with -a true/false.

- Description for the changelog

Add -a option to service/node ps

Signed-off-by: Josh Horwitz [email protected]

@jhorwit2
Copy link
Contributor Author

cc @thaJeztah @stevvooe @aluzzardi

Also, I'll try to remove the self code later today in favor of the other PR mentioned.

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Aug 24, 2016
@jhorwit2
Copy link
Contributor Author

Whoops, I guess Gordon + Update Branch button = not friends.

@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Aug 24, 2016
Args: cli.RequiresMinArgs(1),
Use: "inspect [OPTIONS] [NODE...]",
Short: "Display detailed information on one or more nodes (default to current node)",
Args: nil,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of nil could you use cobra.ArbitraryArgs so it's more explicit about what args are accepted?

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'm gonna be removing this shortly as it's covered in another PR by someone else. The only logic that will be in this one is the -a flag stuff.

@thaJeztah
Copy link
Member

design LGTM. Moving to code review

@thaJeztah
Copy link
Member

for the API - should this change be versioned? (i.e., for API 1.24 ignore the "all" option, and default to "all", for API 1.25 the opposite?)

@@ -292,6 +292,7 @@ type ServiceListOptions struct {
// TaskListOptions holds parameters to list tasks with.
type TaskListOptions struct {
Filter filters.Args
All bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't require such a literal API change. Shouldn't an empty filter send all?

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 was following the same pattern in docker ps to keep it consistent. I agree though 👍

@stevvooe
Copy link
Contributor

We need to be careful about the meaning of "all" here. In a cluster, this is very tricky. Most of the filtering here should be done on the client-side.

Also, right now, we mostly already show everything, so this PR would restrict to only running tasks (or preparing/starting, as well). Let's make sure that change is what we want.

cc @aluzzardi

@jhorwit2
Copy link
Contributor Author

@stevvooe Why do you think filtering should be done client-side? The logic is already in swarm to filter tasks, which reduces bytes over the wire. The result could be pretty large in a bigger cluster. Also, costly if you require quorum on each task returned.

What exactly are you worried about with "all" here? In this case, it really is all because the daemon is requesting a list from a manager. The UX here seems very similar to that of docker ps.

@@ -5088,6 +5088,9 @@ List tasks

**Query parameters**:

- **all** – 1/True/true or 0/False/false, Show all containers.
Only tasks that will be running or are currently running are shown by default(i.e., this defaults to false)

Copy link
Member

@dnephin dnephin Sep 26, 2016

Choose a reason for hiding this comment

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

I think v1.24 is already released, so it shouldn't be added here.

c.Assert(out, checker.Count, name, 2)
c.Assert(out, checker.Contains, "Running")
c.Assert(out, checker.Contains, "Shutdown")
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it's at least a couple different cases. I think this should be split up into different tests with a descriptive name of each case.

@stevvooe
Copy link
Contributor

What exactly are you worried about with "all" here?

Does "all" really mean all or will it come to mean the output that is shown with -a?

Don't bind UX to API. We keep making this mistake and it makes this project impossible to work on because I keep finding UX buried deep in the backend.

@thaJeztah
Copy link
Member

ping @stevvooe what do you suggest for changes? Is there some way to unblock this PR?

@stevvooe
Copy link
Contributor

stevvooe commented Nov 3, 2016

@thaJeztah By default, without a filter, the tasks endpoint should already return all. The standard mode in CLI should filter by state (all tasks <=running) and -a should be without a filter.

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Nov 3, 2016

Sounds good to me.

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Nov 3, 2016

@stevvooe PTAL.

@jhorwit2 jhorwit2 changed the title Add -a option to service/node ps to show not running tasks Add -a option to service/node ps Nov 3, 2016
@thaJeztah
Copy link
Member

One nit in docs, but LGTM otherwise

Also, am I missing autocomplete files?

Yeah, this needs changes to those https://github.com/docker/docker/tree/master/contrib/completion, but we can also do those in a follow up if you prefer

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Nov 6, 2016

@thaJeztah follow up PR sounds good to me. I made a ticket #28108

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

/cc @vdemeester

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐸

@vdemeester vdemeester merged commit 89ef0f2 into moby:master Nov 7, 2016
@jhorwit2 jhorwit2 added this to the 1.13.0 milestone Nov 7, 2016
@aaronlehmann
Copy link
Contributor

TBH I'm not a fan of this change. It's a big UI change from 1.12.x and I think it will be confusing to users.

I just encountered it while using 1.13.0-rc1. I was trying to understand why a service wasn't starting, and docker service ps showed me nothing:

# docker service ps my_wordpress_db
NAME  IMAGE  NODE  DESIRED STATE  CURRENT STATE  ERROR  PORTS

I eventually discovered docker service ps -a, and then I could see the failed tasks.

@aaronlehmann
Copy link
Contributor

I would suggest changing this so that we do show failed tasks by default, if there's no currently running tasks.

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Nov 16, 2016

@aaronlehmann this is no different from how you would look into a container in docker ps that failed. You think it's good to have different UX across ps commands? As a user, that inconsistency across subcommands has always been confusing to me.

@jhorwit2 jhorwit2 deleted the jah/ps-refactor branch November 16, 2016 21:57
yongtang added a commit to yongtang/docker that referenced this pull request Dec 26, 2016
…ps -a`

In moby#28507 and moby#28885, `docker service/node ps -a` has been removed so that
information about slots are show up even without `-a` flag.

The output of `docker stack ps` reused the same output as `docker service/node ps`.
However, the `-a` was still there. It might make sense to remove `docker stack ps -a`
as well to bring consistency with `docker service/node ps`.

This fix is related to moby#28507, moby#28885, and moby#25983.

Signed-off-by: Yong Tang <[email protected]>
vdemeester pushed a commit to vieux/docker that referenced this pull request Jan 4, 2017
…ps -a`

In moby#28507 and moby#28885, `docker service/node ps -a` has been removed so that
information about slots are show up even without `-a` flag.

The output of `docker stack ps` reused the same output as `docker service/node ps`.
However, the `-a` was still there. It might make sense to remove `docker stack ps -a`
as well to bring consistency with `docker service/node ps`.

This fix is related to moby#28507, moby#28885, and moby#25983.

Signed-off-by: Yong Tang <[email protected]>
(cherry picked from commit 9155e14)
Signed-off-by: Victor Vieux <[email protected]>
Signed-off-by: Vincent Demeester <[email protected]>
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
…ps -a`

In moby#28507 and moby#28885, `docker service/node ps -a` has been removed so that
information about slots are show up even without `-a` flag.

The output of `docker stack ps` reused the same output as `docker service/node ps`.
However, the `-a` was still there. It might make sense to remove `docker stack ps -a`
as well to bring consistency with `docker service/node ps`.

This fix is related to moby#28507, moby#28885, and moby#25983.

Signed-off-by: Yong Tang <[email protected]>
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.

Provide option to hide task history on docker service ps docker node ps should have all option
8 participants