Add output to runsc trace commands

Otherwise it's hard to tell if the command succeeded or not.

Updates #4805

PiperOrigin-RevId: 467807571
This commit is contained in:
Fabricio Voznika
2022-08-15 18:13:58 -07:00
committed by gVisor bot
parent 2dbd37fd74
commit 2bb73c7bd7
2 changed files with 8 additions and 4 deletions
+1
View File
@@ -90,6 +90,7 @@ func (l *create) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}
util.Fatalf("creating session: %v", err)
}
fmt.Printf("Trace session %q created.\n", sessionConfig.Name)
return subcommands.ExitSuccess
}
+7 -4
View File
@@ -16,6 +16,7 @@ package trace
import (
"context"
"fmt"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/cmd/util"
@@ -26,7 +27,7 @@ import (
// delete implements subcommands.Command for the "delete" command.
type delete struct {
name string
sessionName string
}
// Name implements subcommands.Command.
@@ -47,7 +48,7 @@ func (*delete) Usage() string {
// SetFlags implements subcommands.Command.
func (l *delete) SetFlags(f *flag.FlagSet) {
f.StringVar(&l.name, "name", "", "name of session to be deleted")
f.StringVar(&l.sessionName, "name", "", "name of session to be deleted")
}
// Execute implements subcommands.Command.
@@ -56,7 +57,7 @@ func (l *delete) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}
f.Usage()
return subcommands.ExitUsageError
}
if len(l.name) == 0 {
if len(l.sessionName) == 0 {
f.Usage()
return util.Errorf("missing session name, please set --name")
}
@@ -73,8 +74,10 @@ func (l *delete) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}
util.Fatalf("loading sandbox: %v", err)
}
if err := c.Sandbox.DeleteTraceSession(l.name); err != nil {
if err := c.Sandbox.DeleteTraceSession(l.sessionName); err != nil {
util.Fatalf("deleting session: %v", err)
}
fmt.Printf("Trace session %q deleted.\n", l.sessionName)
return subcommands.ExitSuccess
}