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 --no-trunc to service/node/stack ps output #25337

Merged
merged 1 commit into from
Aug 16, 2016

Conversation

jhorwit2
Copy link
Contributor

@jhorwit2 jhorwit2 commented Aug 2, 2016

closes #25332

- What I did

Added --no-trunc option like docker ps has to docker service ps, docker node ps and docker stack ps. Currently only errors were being truncated.

- How I did it

Added cli option to the 3 commands & check for it in task.Print

- How to verify it

Create a service that has tasks that error out -> run docker node ps self --no-trunc to see the full error.

$ docker swarm init
$ echo 'FROM busybox \
      HEALTHCHECK --interval=1s --timeout=1s CMD ls /foo \
     CMD top' | docker build -t test_none -

$ docker service create --name test test_none
1ktygqey58cgpz43p54tl35e3

$ docker node ps self
ID                         NAME        IMAGE      NODE          DESIRED STATE  CURRENT STATE         ERROR
4nb1pvcty3a7co574cg6kscaf  test.1      test_none  e96bbd330fee  Ready          Ready 1 seconds ago
7fjobb83ee0k3dmxfky0qalpd   \_ test.1  test_none  e96bbd330fee  Shutdown       Failed 2 seconds ago  "task: non-zero exit (137): do…"

$ docker node ps self --no-trunc
ID                         NAME        IMAGE      NODE          DESIRED STATE  CURRENT STATE           ERROR
4nb1pvcty3a7co574cg6kscaf  test.1      test_none  e96bbd330fee  Running        Starting 1 seconds ago
7fjobb83ee0k3dmxfky0qalpd   \_ test.1  test_none  e96bbd330fee  Shutdown       Failed 6 seconds ago    "task: non-zero exit (137): dockerexec: unhealthy container"

$ docker service ps test --no-trunc
ID                         NAME        IMAGE      NODE          DESIRED STATE  CURRENT STATE           ERROR
279eltuipxm8sbz19syl8a1o9  test.1      test_none  e96bbd330fee  Running        Starting 4 seconds ago
4nb1pvcty3a7co574cg6kscaf   \_ test.1  test_none  e96bbd330fee  Shutdown       Failed 9 seconds ago    "task: non-zero exit (137): dockerexec: unhealthy container"
7fjobb83ee0k3dmxfky0qalpd   \_ test.1  test_none  e96bbd330fee  Shutdown       Failed 28 seconds ago   "task: non-zero exit (137): dockerexec: unhealthy container"

- Description for the changelog

Add --no-trunc to service/node/stack ps output

Signed-off-by: Josh Horwitz horwitzja@gmail.com

@vdemeester
Copy link
Member

Seems ok to me, although the meaning of no-trunc is a little bit different from the docker ps one (which is on IDs).
/cc @aluzzardi

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Aug 2, 2016

@vdemeester Although that's the only thing docker ps truncates currently the docs don't specify that. It only says --no-trunc Don't truncate output

@thaJeztah
Copy link
Member

I think no-trunc is ok; docker history also uses it, and that affects other fields

@@ -41,7 +41,7 @@ func (t tasksBySlot) Less(i, j int) bool {
}

// Print task information in a table format
func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver) error {
func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver, noTrunc bool) error {
Copy link
Member

Choose a reason for hiding this comment

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

should we inverse this, and make this trunc? Maybe just preference, but not really fond of the double negative :D

happy to hear what others think

Copy link
Contributor Author

@jhorwit2 jhorwit2 Aug 2, 2016

Choose a reason for hiding this comment

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

So i had the same thought but docker ps passes it around as noTrunc so i kept it.

@thaJeztah
Copy link
Member

design +1

@thaJeztah
Copy link
Member

don't forget the completion scripts; probably something like this;

diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker
index f3a7407..139bfbe 100644
--- a/contrib/completion/bash/docker
+++ b/contrib/completion/bash/docker
@@ -1690,7 +1690,7 @@ _docker_service_ps() {

        case "$cur" in
                -*)
-                       COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve" -- "$cur" ) )
+                       COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc" -- "$cur" ) )
                        ;;
                *)
                        local counter=$(__docker_pos_first_nonflag '--filter|-f')
@@ -2049,7 +2049,7 @@ _docker_node_ps() {

        case "$cur" in
                -*)
-                       COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve" -- "$cur" ) )
+                       COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc" -- "$cur" ) )
                        ;;
                *)
                        local counter=$(__docker_pos_first_nonflag '--filter|-f')
diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker
index 1eed282..6ccfdd5 100644
--- a/contrib/completion/zsh/_docker
+++ b/contrib/completion/zsh/_docker
@@ -840,6 +840,7 @@ __docker_node_subcommand() {
                 "($help -a --all)"{-a,--all}"[Display all instances]" \
                 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
                 "($help)--no-resolve[Do not map IDs to Names]" \
+                "($help)--no-trunc[Do not truncate output]" \
                 "($help -)1:node:__docker_complete_nodes" && ret=0
             case $state in
                 (filter-options)
@@ -1155,6 +1156,7 @@ __docker_service_subcommand() {
                 "($help -a --all)"{-a,--all}"[Display all tasks]" \
                 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
                 "($help)--no-resolve[Do not map IDs to Names]" \
+                "($help)--no-trunc[Do not truncate output]" \
                 "($help -)1:service:__docker_complete_services" && ret=0
             case $state in
                 (filter-options)

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Aug 2, 2016

@thaJeztah no love for fish shell 😢

@thaJeztah
Copy link
Member

@jhorwit2 I think it's in need of some love yes; IIRC it has a script to update automatically, but it's been a while since I looked at it

@crosbymichael
Copy link
Contributor

@jhorwit2 can you make the changes for s/Don't/ Do not then I think this is good to merge.

Thanks!

@jhorwit2
Copy link
Contributor Author

@crosbymichael 👍 done

Signed-off-by: Josh Horwitz <horwitzja@gmail.com>
@thaJeztah
Copy link
Member

LGTM

@crosbymichael
Copy link
Contributor

LGTM

@Vanuan
Copy link

Vanuan commented Oct 9, 2016

Is it released? I've got unknown flag: --no-trunc

@thaJeztah
Copy link
Member

@Vanuan it's on the 1.13 milestone, so will be part of that release. If you want to live on the edge, you can download static binaries from https://master.dockerproject.org

@skobkin
Copy link

skobkin commented Aug 31, 2018

How about --no-trunc for docker service create?

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.

docker service ps option to prevent truncating error messages
7 participants