Skip to content

Commit

Permalink
crictl: add Runtime column for RuntimeHandler
Browse files Browse the repository at this point in the history
If the RuntimeHandler is empty, show (default) as CRI's default runtime.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid committed May 2, 2020
1 parent e9d8804 commit 923dd0c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
33 changes: 17 additions & 16 deletions cmd/crictl/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,23 @@ import (
)

const (
columnContainer = "CONTAINER"
columnImage = "IMAGE"
columnImageID = "IMAGE ID"
columnCreated = "CREATED"
columnState = "STATE"
columnName = "NAME"
columnAttempt = "ATTEMPT"
columnPodID = "POD ID"
columnNamespace = "NAMESPACE"
columnSize = "SIZE"
columnTag = "TAG"
columnDigest = "DIGEST"
columnMemory = "MEM"
columnInodes = "INODES"
columnDisk = "DISK"
columnCPU = "CPU %"
columnContainer = "CONTAINER"
columnImage = "IMAGE"
columnImageID = "IMAGE ID"
columnCreated = "CREATED"
columnState = "STATE"
columnName = "NAME"
columnAttempt = "ATTEMPT"
columnPodID = "POD ID"
columnPodRuntime = "Runtime"
columnNamespace = "NAMESPACE"
columnSize = "SIZE"
columnTag = "TAG"
columnDigest = "DIGEST"
columnMemory = "MEM"
columnInodes = "INODES"
columnDisk = "DISK"
columnCPU = "CPU %"
)

// display use to output something on screen with table format.
Expand Down
30 changes: 27 additions & 3 deletions cmd/crictl/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,15 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error {

display := newTableDisplay(20, 1, 3, ' ', 0)
if !opts.verbose && !opts.quiet {
display.AddRow([]string{columnPodID, columnCreated, columnState, columnName, columnNamespace, columnAttempt})
display.AddRow([]string{
columnPodID,
columnCreated,
columnState,
columnName,
columnNamespace,
columnAttempt,
columnPodRuntime,
})
}
for _, pod := range r.Items {
if opts.quiet {
Expand All @@ -518,8 +526,15 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error {
if !opts.noTrunc {
id = getTruncatedID(id, "")
}
display.AddRow([]string{id, ctm, convertPodState(pod.State), pod.Metadata.Name,
pod.Metadata.Namespace, fmt.Sprintf("%d", pod.Metadata.Attempt)})
display.AddRow([]string{
id,
ctm,
convertPodState(pod.State),
pod.Metadata.Name,
pod.Metadata.Namespace,
fmt.Sprintf("%d", pod.Metadata.Attempt),
getSandboxesRuntimeHandler(pod),
})
continue
}

Expand Down Expand Up @@ -553,6 +568,8 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error {
fmt.Printf("\t%s -> %s\n", k, pod.Annotations[k])
}
}
fmt.Printf("%s: %s\n", columnPodRuntime, getSandboxesRuntimeHandler(pod))

fmt.Println()
}

Expand All @@ -572,6 +589,13 @@ func convertPodState(state pb.PodSandboxState) string {
}
}

func getSandboxesRuntimeHandler(sandbox *pb.PodSandbox) string {
if sandbox.RuntimeHandler == "" {
return "(default)"
}
return sandbox.RuntimeHandler
}

func getSandboxesList(sandboxesList []*pb.PodSandbox, opts listOptions) []*pb.PodSandbox {
filtered := []*pb.PodSandbox{}
for _, p := range sandboxesList {
Expand Down

0 comments on commit 923dd0c

Please sign in to comment.