From 2adfd20ac9dcaf2824959e4989983c6a1790a800 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 3 May 2020 02:11:02 +0200 Subject: [PATCH] libcontainer: don't double-quote errors genericError.Error() was formatting the underlying error using `%q`; as a result, quotes in underlying errors were escaped multiple times, which caused the output to become hard to read, for example (wrapped for readability): ``` container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/foo.txt\\\" to rootfs \\\"/var/lib/docker/overlay2/f49a0ae0ec6646c818dcf05dbcbbdd79fc7c42561f3684fbb1fc5d2b9d3ad192/merged\\\" at \\\"/var/lib/docker/overlay2/f49a0ae0ec6646c818dcf05dbcbbdd79fc7c42561f3684fbb1fc5d2b9d3ad192/merged/usr/share/nginx/html\\\" caused \\\"not a directory\\\"\"": unknown ``` With this patch applied: ``` container_linux.go:348: starting container process caused: process_linux.go:438: container init caused: rootfs_linux.go:58: mounting "/foo.txt" to rootfs "/var/lib/docker/overlay2/de506d67da606b807009e23b548fec60d72359c77eec88785d8c7ecd54a6e4b2/merged" at "/var/lib/docker/overlay2/de506d67da606b807009e23b548fec60d72359c77eec88785d8c7ecd54a6e4b2/merged/usr/share/nginx/html" caused: not a directory: unknown ``` Signed-off-by: Sebastiaan van Stijn --- libcontainer/generic_error.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainer/generic_error.go b/libcontainer/generic_error.go index 6e7de2fe..d185ebd8 100644 --- a/libcontainer/generic_error.go +++ b/libcontainer/generic_error.go @@ -80,7 +80,7 @@ func (e *genericError) Error() string { return e.Message } frame := e.Stack.Frames[0] - return fmt.Sprintf("%s:%d: %s caused %q", frame.File, frame.Line, e.Cause, e.Message) + return fmt.Sprintf("%s:%d: %s caused: %s", frame.File, frame.Line, e.Cause, e.Message) } func (e *genericError) Code() ErrorCode {