diff options
author | Ian Lewis <ianlewis@google.com> | 2018-11-01 17:39:20 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-11-01 17:40:09 -0700 |
commit | 9d69d85bc13d4f0956a39951b5cd6777f938cffd (patch) | |
tree | a616e7277ab1712dd23b505c33591d1bc1e0cab2 /pkg/sentry | |
parent | 0e277a39c8b6f905e289b75e8ad0594e6b3562ca (diff) |
Make error messages a bit more user friendly.
Updated error messages so that it doesn't print full Go struct representations
when running a new container in a sandbox. For example, this occurs frequently
when commands are not found when doing a 'kubectl exec'.
PiperOrigin-RevId: 219729141
Change-Id: Ic3a7bc84cd7b2167f495d48a1da241d621d3ca09
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/control/proc.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/sentry/control/proc.go b/pkg/sentry/control/proc.go index b6ac2f312..923399fb2 100644 --- a/pkg/sentry/control/proc.go +++ b/pkg/sentry/control/proc.go @@ -19,6 +19,7 @@ import ( "encoding/json" "fmt" "sort" + "strings" "text/tabwriter" "time" @@ -88,6 +89,16 @@ type ExecArgs struct { ContainerID string } +// String prints the arguments as a string. +func (args ExecArgs) String() string { + a := make([]string, len(args.Argv)) + copy(a, args.Argv) + if args.Filename != "" { + a[0] = args.Filename + } + return strings.Join(a, " ") +} + // Exec runs a new task. func (proc *Proc) Exec(args *ExecArgs, waitStatus *uint32) error { newTG, _, _, err := proc.execAsync(args) |