-
Notifications
You must be signed in to change notification settings - Fork 456
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
adding verbose debug output for inspect & inspects #206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,6 +221,10 @@ var containerStatusCommand = cli.Command{ | |
Name: "output, o", | ||
Usage: "Output format, One of: json|yaml|table", | ||
}, | ||
cli.BoolFlag{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for inspect, we should always set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Random-Liu so you are saying you want a --quiet option for less verbose? or take out the option all-together? There were already other verbose flags so I figured that's what we would want with this verbose option. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like by default we should enable verbose, or else it's really troublesome to do -v every time. :) As for whether we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Random-Liu I hear ya.. think it over no rush, easy enough to switch it to verbose by default, or quiet mode option. But I think when you see the verbose mode from the CRI-O team you'll be begging to turn down the volume :-) @runcom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? Not following, what about CRI-O? We aren't even using that verbose stuff and we have no plan to output anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 of enabling verbose. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just making light of the amount of metadata CRI-O keeps around that could possibly used in a verbose output of status about the container, thus the smiley face :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah but that's exactly the verbose intention, despite what runtimes want to output There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vote inspect to be verbose by default for crictl (and provide a silent flag to turn verbose off). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done.. |
||
Name: "quiet, q", | ||
Usage: "Do not show verbose information", | ||
}, | ||
}, | ||
Action: func(context *cli.Context) error { | ||
containerID := context.Args().First() | ||
|
@@ -232,7 +236,7 @@ var containerStatusCommand = cli.Command{ | |
return err | ||
} | ||
|
||
err := ContainerStatus(runtimeClient, containerID, context.String("output")) | ||
err := ContainerStatus(runtimeClient, containerID, context.String("output"), context.Bool("quiet")) | ||
if err != nil { | ||
return fmt.Errorf("Getting the status of the container failed: %v", err) | ||
} | ||
|
@@ -462,12 +466,17 @@ func RemoveContainer(client pb.RuntimeServiceClient, ID string) error { | |
|
||
// ContainerStatus sends a ContainerStatusRequest to the server, and parses | ||
// the returned ContainerStatusResponse. | ||
func ContainerStatus(client pb.RuntimeServiceClient, ID, output string) error { | ||
func ContainerStatus(client pb.RuntimeServiceClient, ID, output string, quiet bool) error { | ||
verbose := !(quiet) | ||
if output == "" { // default to json output | ||
output = "json" | ||
} | ||
if ID == "" { | ||
return fmt.Errorf("ID cannot be empty") | ||
} | ||
request := &pb.ContainerStatusRequest{ | ||
ContainerId: ID, | ||
Verbose: verbose, | ||
} | ||
logrus.Debugf("ContainerStatusRequest: %v", request) | ||
r, err := client.ContainerStatus(context.Background(), request) | ||
|
@@ -476,11 +485,15 @@ func ContainerStatus(client pb.RuntimeServiceClient, ID, output string) error { | |
return err | ||
} | ||
|
||
if output == "json" || output == "yaml" { | ||
switch output { | ||
case "json", "yaml": | ||
return outputStatusInfo(r.Status, r.Info, output) | ||
case "table": // table output is after this switch block | ||
default: | ||
return fmt.Errorf("output option cannot be %s", output) | ||
} | ||
|
||
// output in table format by default. | ||
// output in table format | ||
fmt.Printf("ID: %s\n", r.Status.Id) | ||
if r.Status.Metadata != nil { | ||
if r.Status.Metadata.Name != "" { | ||
|
@@ -504,6 +517,9 @@ func ContainerStatus(client pb.RuntimeServiceClient, ID, output string) error { | |
} | ||
fmt.Printf("Exit Code: %v\n", r.Status.ExitCode) | ||
} | ||
if verbose { | ||
fmt.Printf("Info: %v\n", r.GetInfo()) | ||
} | ||
|
||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feiskyer @mrunalp @runcom @mikebrow Do you still think we should have the
table
format?I think for inspect, we may just need
json|yaml
. Just likecrictl info
. See an example hereThe problem is that timestamp in CRI is unix timestamp, we may want to do a conversion in crictl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of table, let's drop it in favor of machine readable output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of table formats either, but as @Random-Liu says the unix timestamp is not human readable output:
vs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do some conversion there, not a big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should do some conversion. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, table is not useful for inspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so.. @Random-Liu @runcom @feiskyer wrt. "some conversion"
I suggest converting the timestamps to RFC3339Nano
"2006-01-02T15:04:05.999999999Z07:00"
Thoughts?