Skip to content

Commit

Permalink
podman ps truncate the command
Browse files Browse the repository at this point in the history
With a long create command the
output from ps is basically unreadable.

This is a regression that was introduced with Podman 2.0.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Paul Holzinger authored and skorhone committed Jul 7, 2020
1 parent 57b7385 commit a8768f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/podman/containers/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,13 @@ func (l psReporter) Status() string {

// Command returns the container command in string format
func (l psReporter) Command() string {
return strings.Join(l.ListContainer.Command, " ")
command := strings.Join(l.ListContainer.Command, " ")
if !noTrunc {
if len(command) > 17 {
return command[0:17] + "..."
}
}
return command
}

// Size returns the rootfs and virtual sizes in human duration in
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,15 @@ var _ = Describe("Podman ps", func() {
Expect(ps.ExitCode()).To(Equal(0))
Expect(ps.OutputToString()).To(ContainSubstring("0.0.0.0:8080->80/tcp"))
})

It("podman ps truncate long create commad", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "echo", "very", "long", "create", "command"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

session = podmanTest.Podman([]string{"ps", "-a"})
session.WaitWithDefaultTimeout()
Expect(session.OutputToString()).To(ContainSubstring("echo very long cr..."))
})

})

0 comments on commit a8768f5

Please sign in to comment.